Sha256: 3438851db62b7449317f412a88357c0e39ecf501e170c7f1ee13680a5bee56ca
Contents?: true
Size: 1.15 KB
Versions: 66
Compression:
Stored size: 1.15 KB
Contents
var ctx = require('./_ctx'); var call = require('./_iter-call'); var isArrayIter = require('./_is-array-iter'); var anObject = require('./_an-object'); var toLength = require('./_to-length'); var getIterFn = require('./core.get-iterator-method'); var BREAK = {}; var RETURN = {}; var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) { var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable); var f = ctx(fn, that, entries ? 2 : 1); var index = 0; var length, step, iterator, result; if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!'); // fast case for arrays with default iterator if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) { result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]); if (result === BREAK || result === RETURN) return result; } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) { result = call(iterator, f, step.value, entries); if (result === BREAK || result === RETURN) return result; } }; exports.BREAK = BREAK; exports.RETURN = RETURN;
Version data entries
66 entries across 30 versions & 8 rubygems