source: frontend/node_modules/underscore/modules/each.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 719 bytes
Line 
1import optimizeCb from './_optimizeCb.js';
2import isArrayLike from './_isArrayLike.js';
3import keys from './keys.js';
4
5// The cornerstone for collection functions, an `each`
6// implementation, aka `forEach`.
7// Handles raw objects in addition to array-likes. Treats all
8// sparse array-likes as if they were dense.
9export default function each(obj, iteratee, context) {
10 iteratee = optimizeCb(iteratee, context);
11 var i, length;
12 if (isArrayLike(obj)) {
13 for (i = 0, length = obj.length; i < length; i++) {
14 iteratee(obj[i], i, obj);
15 }
16 } else {
17 var _keys = keys(obj);
18 for (i = 0, length = _keys.length; i < length; i++) {
19 iteratee(obj[_keys[i]], _keys[i], obj);
20 }
21 }
22 return obj;
23}
Note: See TracBrowser for help on using the repository browser.