You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
529 B
18 lines
529 B
var isArrLike = require('./isArrLike'); |
|
var keys = require('./keys'); |
|
var optimizeCb = require('./optimizeCb'); |
|
exports = function(obj, iterator, ctx) { |
|
iterator = optimizeCb(iterator, ctx); |
|
var i, len; |
|
if (isArrLike(obj)) { |
|
for (i = 0, len = obj.length; i < len; i++) iterator(obj[i], i, obj); |
|
} else { |
|
var _keys = keys(obj); |
|
for (i = 0, len = _keys.length; i < len; i++) { |
|
iterator(obj[_keys[i]], _keys[i], obj); |
|
} |
|
} |
|
return obj; |
|
}; |
|
|
|
module.exports = exports;
|
|
|