aboutsummaryrefslogtreecommitdiff
path: root/node_modules/lodash/_createAggregator.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/lodash/_createAggregator.js')
-rw-r--r--node_modules/lodash/_createAggregator.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/node_modules/lodash/_createAggregator.js b/node_modules/lodash/_createAggregator.js
new file mode 100644
index 0000000..0be42c4
--- /dev/null
+++ b/node_modules/lodash/_createAggregator.js
@@ -0,0 +1,23 @@
+var arrayAggregator = require('./_arrayAggregator'),
+ baseAggregator = require('./_baseAggregator'),
+ baseIteratee = require('./_baseIteratee'),
+ isArray = require('./isArray');
+
+/**
+ * Creates a function like `_.groupBy`.
+ *
+ * @private
+ * @param {Function} setter The function to set accumulator values.
+ * @param {Function} [initializer] The accumulator object initializer.
+ * @returns {Function} Returns the new aggregator function.
+ */
+function createAggregator(setter, initializer) {
+ return function(collection, iteratee) {
+ var func = isArray(collection) ? arrayAggregator : baseAggregator,
+ accumulator = initializer ? initializer() : {};
+
+ return func(collection, setter, baseIteratee(iteratee, 2), accumulator);
+ };
+}
+
+module.exports = createAggregator;