source: trip-planner-front/node_modules/lodash/forEach.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.3 KB
Line 
1var arrayEach = require('./_arrayEach'),
2 baseEach = require('./_baseEach'),
3 castFunction = require('./_castFunction'),
4 isArray = require('./isArray');
5
6/**
7 * Iterates over elements of `collection` and invokes `iteratee` for each element.
8 * The iteratee is invoked with three arguments: (value, index|key, collection).
9 * Iteratee functions may exit iteration early by explicitly returning `false`.
10 *
11 * **Note:** As with other "Collections" methods, objects with a "length"
12 * property are iterated like arrays. To avoid this behavior use `_.forIn`
13 * or `_.forOwn` for object iteration.
14 *
15 * @static
16 * @memberOf _
17 * @since 0.1.0
18 * @alias each
19 * @category Collection
20 * @param {Array|Object} collection The collection to iterate over.
21 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
22 * @returns {Array|Object} Returns `collection`.
23 * @see _.forEachRight
24 * @example
25 *
26 * _.forEach([1, 2], function(value) {
27 * console.log(value);
28 * });
29 * // => Logs `1` then `2`.
30 *
31 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
32 * console.log(key);
33 * });
34 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
35 */
36function forEach(collection, iteratee) {
37 var func = isArray(collection) ? arrayEach : baseEach;
38 return func(collection, castFunction(iteratee));
39}
40
41module.exports = forEach;
Note: See TracBrowser for help on using the repository browser.