Creates an object composed of keys generated from the results of running each element of `collection` thru `iteratee`. The order of grouped values is determined by the order they occur in `collection`. The corresponding value of each key is an array of elements responsible for generating the key. The iteratee is invoked with one argument: (value).
groupBy([6.1, 4.2, 6.3], Math.floor)
// => { '4': [4.2], '6': [6.1, 6.3] }
Name | Type | Attribute | Description |
---|---|---|---|
collection | The collection to iterate over. | ||
iteratee | The iteratee to transform keys. |
{ "comment": "/**\r\n * Creates an object composed of keys generated from the results of running\r\n * each element of `collection` thru `iteratee`. The order of grouped values\r\n * is determined by the order they occur in `collection`. The corresponding\r\n * value of each key is an array of elements responsible for generating the\r\n * key. The iteratee is invoked with one argument: (value).\r\n *\r\n * @since 0.1.0\r\n * @category Collection\r\n * @param {Array|Object} collection The collection to iterate over.\r\n * @param {Function} iteratee The iteratee to transform keys.\r\n * @returns {Object} Returns the composed aggregate object.\r\n * @example\r\n *\r\n * groupBy([6.1, 4.2, 6.3], Math.floor)\r\n * // => { '4': [4.2], '6': [6.1, 6.3] }\r\n */", "meta": { "range": [ 925, 1221 ], "filename": "groupBy.js", "lineno": 24, "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo", "code": { "id": "astnode100003155", "name": "groupBy", "type": "FunctionDeclaration", "paramnames": [ "collection", "iteratee" ] }, "vars": { "": null } }, "description": "Creates an object composed of keys generated from the results of running\reach element of `collection` thru `iteratee`. The order of grouped values\ris determined by the order they occur in `collection`. The corresponding\rvalue of each key is an array of elements responsible for generating the\rkey. The iteratee is invoked with one argument: (value).", "since": "0.1.0", "tags": [ { "originalTitle": "category", "title": "category", "text": "Collection", "value": "Collection" } ], "params": [ { "type": { "names": [ "Array", "Object" ] }, "description": "The collection to iterate over.", "name": "collection" }, { "type": { "names": [ "function" ] }, "description": "The iteratee to transform keys.", "name": "iteratee" } ], "returns": [ { "type": { "names": [ "Object" ] }, "description": "Returns the composed aggregate object." } ], "examples": [ "groupBy([6.1, 4.2, 6.3], Math.floor)\r// => { '4': [4.2], '6': [6.1, 6.3] }" ], "name": "groupBy", "longname": "groupBy", "kind": "function", "scope": "global", "___id": "T000002R000334", "___s": true, "filepath": "groupBy.js" }