fdsfd
This commit is contained in:
parent
628618df89
commit
e031240dff
3749 changed files with 1120848 additions and 1 deletions
41
node_modules/lodash/groupBy.js
generated
vendored
Normal file
41
node_modules/lodash/groupBy.js
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
var baseAssignValue = require('./_baseAssignValue'),
|
||||
createAggregator = require('./_createAggregator');
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* 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).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Collection
|
||||
* @param {Array|Object} collection The collection to iterate over.
|
||||
* @param {Function} [iteratee=_.identity] The iteratee to transform keys.
|
||||
* @returns {Object} Returns the composed aggregate object.
|
||||
* @example
|
||||
*
|
||||
* _.groupBy([6.1, 4.2, 6.3], Math.floor);
|
||||
* // => { '4': [4.2], '6': [6.1, 6.3] }
|
||||
*
|
||||
* // The `_.property` iteratee shorthand.
|
||||
* _.groupBy(['one', 'two', 'three'], 'length');
|
||||
* // => { '3': ['one', 'two'], '5': ['three'] }
|
||||
*/
|
||||
var groupBy = createAggregator(function(result, value, key) {
|
||||
if (hasOwnProperty.call(result, key)) {
|
||||
result[key].push(value);
|
||||
} else {
|
||||
baseAssignValue(result, key, [value]);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = groupBy;
|
Loading…
Add table
Add a link
Reference in a new issue