Sha256: 8c804ff21ceb97f4c02e64c62337e916dbd651c2da581ab117653f963b2cf635

Contents?: true

Size: 1.32 KB

Versions: 264

Compression:

Stored size: 1.32 KB

Contents

var arrayEach = require('./_arrayEach'),
    baseEach = require('./_baseEach'),
    castFunction = require('./_castFunction'),
    isArray = require('./isArray');

/**
 * Iterates over elements of `collection` and invokes `iteratee` for each element.
 * The iteratee is 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 use `_.forIn`
 * or `_.forOwn` for object iteration.
 *
 * @static
 * @memberOf _
 * @since 0.1.0
 * @alias each
 * @category Collection
 * @param {Array|Object} collection The collection to iterate over.
 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
 * @returns {Array|Object} Returns `collection`.
 * @see _.forEachRight
 * @example
 *
 * _.forEach([1, 2], function(value) {
 *   console.log(value);
 * });
 * // => Logs `1` then `2`.
 *
 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
 *   console.log(key);
 * });
 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
 */
function forEach(collection, iteratee) {
  var func = isArray(collection) ? arrayEach : baseEach;
  return func(collection, castFunction(iteratee));
}

module.exports = forEach;

Version data entries

264 entries across 262 versions & 29 rubygems

Version Path
trusty-cms-6.3.1 node_modules/lodash/forEach.js
immosquare-cleaner-0.1.51 node_modules/lodash/forEach.js
boring_generators-0.15.0 tmp/templates/app_template/node_modules/lodash/forEach.js
clapton-0.0.26 lib/clapton/javascripts/node_modules/lodash/forEach.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/lodash/forEach.js
immosquare-cleaner-0.1.50 node_modules/lodash/forEach.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/lodash/forEach.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/lodash/forEach.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/lodash/forEach.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/lodash/forEach.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/lodash/forEach.js
clapton-0.0.19 lib/clapton/javascripts/node_modules/lodash/forEach.js
clapton-0.0.18 lib/clapton/javascripts/node_modules/lodash/forEach.js
clapton-0.0.17 lib/clapton/javascripts/node_modules/lodash/forEach.js
clapton-0.0.16 lib/clapton/javascripts/node_modules/lodash/forEach.js
clapton-0.0.15 lib/clapton/javascripts/node_modules/lodash/forEach.js
immosquare-cleaner-0.1.49 node_modules/lodash/forEach.js
clapton-0.0.14 lib/clapton/javascripts/node_modules/lodash/forEach.js
immosquare-cleaner-0.1.48 node_modules/lodash/forEach.js
clapton-0.0.13 lib/clapton/javascripts/node_modules/lodash/forEach.js