|
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:
741 bytes
|
| Line | |
|---|
| 1 | var _optimizeCb = require('./_optimizeCb.js');
|
|---|
| 2 | var _isArrayLike = require('./_isArrayLike.js');
|
|---|
| 3 | var keys = require('./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.
|
|---|
| 9 | 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 | }
|
|---|
| 24 |
|
|---|
| 25 | module.exports = each;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.