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.

26 lines
551 B

'use strict';
module.exports = function each(fn) {
var stop = false;
if (Array.isArray(this.items)) {
var length = this.items.length;
for (var index = 0; index < length && !stop; index += 1) {
stop = fn(this.items[index], index, this.items) === false;
}
} else {
var keys = Object.keys(this.items);
var _length = keys.length;
for (var _index = 0; _index < _length && !stop; _index += 1) {
var key = keys[_index];
stop = fn(this.items[key], key, this.items) === false;
}
}
return this;
};