lodash.groupby
Advanced tools
Comparing version 4.0.1 to 4.0.2
66
index.js
/** | ||
* lodash 4.0.1 (Custom Build) <https://lodash.com/> | ||
* lodash 4.0.2 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
@@ -34,2 +34,23 @@ * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/> | ||
/** | ||
* A specialized version of `baseAggregator` for arrays. | ||
* | ||
* @private | ||
* @param {Array} array The array to iterate over. | ||
* @param {Function} setter The function to set `accumulator` values. | ||
* @param {Function} iteratee The iteratee to transform keys. | ||
* @param {Object} accumulator The initial aggregated object. | ||
* @returns {Function} Returns `accumulator`. | ||
*/ | ||
function arrayAggregator(array, setter, iteratee, accumulator) { | ||
var index = -1, | ||
length = array.length; | ||
while (++index < length) { | ||
var value = array[index]; | ||
setter(accumulator, value, iteratee(value), array); | ||
} | ||
return accumulator; | ||
} | ||
/** Used for built-in method references. */ | ||
@@ -55,2 +76,20 @@ var objectProto = global.Object.prototype; | ||
/** | ||
* Aggregates elements of `collection` on `accumulator` with keys transformed | ||
* by `iteratee` and values set by `setter`. | ||
* | ||
* @private | ||
* @param {Array|Object} collection The collection to iterate over. | ||
* @param {Function} setter The function to set `accumulator` values. | ||
* @param {Function} iteratee The iteratee to transform keys. | ||
* @param {Object} accumulator The initial aggregated object. | ||
* @returns {Function} Returns `accumulator`. | ||
*/ | ||
function baseAggregator(collection, setter, iteratee, accumulator) { | ||
baseEach(collection, function(value, key, collection) { | ||
setter(accumulator, value, iteratee(value), collection); | ||
}); | ||
return accumulator; | ||
} | ||
/** | ||
* The base implementation of `_.get` without support for default values. | ||
@@ -183,4 +222,4 @@ * | ||
* @private | ||
* @param {Function} setter The function to set keys and values of the accumulator object. | ||
* @param {Function} [initializer] The function to initialize the accumulator object. | ||
* @param {Function} setter The function to set accumulator values. | ||
* @param {Function} [initializer] The accumulator object initializer. | ||
* @returns {Function} Returns the new aggregator function. | ||
@@ -190,19 +229,6 @@ */ | ||
return function(collection, iteratee) { | ||
var result = initializer ? initializer() : {}; | ||
iteratee = baseIteratee(iteratee); | ||
var func = isArray(collection) ? arrayAggregator : baseAggregator, | ||
accumulator = initializer ? initializer() : {}; | ||
if (isArray(collection)) { | ||
var index = -1, | ||
length = collection.length; | ||
while (++index < length) { | ||
var value = collection[index]; | ||
setter(result, value, iteratee(value), collection); | ||
} | ||
} else { | ||
baseEach(collection, function(value, key, collection) { | ||
setter(result, value, iteratee(value), collection); | ||
}); | ||
} | ||
return result; | ||
return func(collection, setter, baseIteratee(iteratee), accumulator); | ||
}; | ||
@@ -350,4 +376,2 @@ } | ||
function isObject(value) { | ||
// Avoid a V8 JIT bug in Chrome 19-20. | ||
// See https://code.google.com/p/v8/issues/detail?id=2291 for more details. | ||
var type = typeof value; | ||
@@ -354,0 +378,0 @@ return !!value && (type == 'object' || type == 'function'); |
{ | ||
"name": "lodash.groupby", | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"description": "The lodash method `_.groupBy` exported as a module.", | ||
@@ -8,3 +8,3 @@ "homepage": "https://lodash.com/", | ||
"license": "MIT", | ||
"keywords": "lodash, lodash-modularized, stdlib, util, groupby", | ||
"keywords": "lodash-modularized, groupby", | ||
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)", | ||
@@ -11,0 +11,0 @@ "contributors": [ |
@@ -1,2 +0,2 @@ | ||
# lodash.groupby v4.0.1 | ||
# lodash.groupby v4.0.2 | ||
@@ -18,2 +18,2 @@ The [lodash](https://lodash.com/) method `_.groupBy` exported as a [Node.js](https://nodejs.org/) module. | ||
See the [documentation](https://lodash.com/docs#groupBy) or [package source](https://github.com/lodash/lodash/blob/4.0.1-npm-packages/lodash.groupby) for more details. | ||
See the [documentation](https://lodash.com/docs#groupBy) or [package source](https://github.com/lodash/lodash/blob/4.0.2-npm-packages/lodash.groupby) for more details. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16162
464