summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/lodash/collection/forEach.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/lodash/collection/forEach.js')
-rw-r--r--deps/npm/node_modules/lodash/collection/forEach.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/deps/npm/node_modules/lodash/collection/forEach.js b/deps/npm/node_modules/lodash/collection/forEach.js
new file mode 100644
index 0000000000..05a8e2140e
--- /dev/null
+++ b/deps/npm/node_modules/lodash/collection/forEach.js
@@ -0,0 +1,37 @@
+var arrayEach = require('../internal/arrayEach'),
+ baseEach = require('../internal/baseEach'),
+ createForEach = require('../internal/createForEach');
+
+/**
+ * Iterates over elements of `collection` invoking `iteratee` for each element.
+ * The `iteratee` is bound to `thisArg` and invoked with three arguments:
+ * (value, index|key, collection). Iteratee functions may exit iteration early
+ * by explicitly returning `false`.
+ *
+ * **Note:** As with other "Collections" methods, objects with a "length" property
+ * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn`
+ * may be used for object iteration.
+ *
+ * @static
+ * @memberOf _
+ * @alias each
+ * @category Collection
+ * @param {Array|Object|string} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @param {*} [thisArg] The `this` binding of `iteratee`.
+ * @returns {Array|Object|string} Returns `collection`.
+ * @example
+ *
+ * _([1, 2]).forEach(function(n) {
+ * console.log(n);
+ * }).value();
+ * // => logs each value from left to right and returns the array
+ *
+ * _.forEach({ 'a': 1, 'b': 2 }, function(n, key) {
+ * console.log(n, key);
+ * });
+ * // => logs each value-key pair and returns the object (iteration order is not guaranteed)
+ */
+var forEach = createForEach(arrayEach, baseEach);
+
+module.exports = forEach;