Sha256: 955a0a3b338fffa84b91f59d08db84ea3193ad746ad6a370c18088292d142b48
Contents?: true
Size: 891 Bytes
Versions: 40
Compression:
Stored size: 891 Bytes
Contents
var ctx = require('./$.ctx') , call = require('./$.iter-call') , isArrayIter = require('./$.is-array-iter') , anObject = require('./$.an-object') , toLength = require('./$.to-length') , getIterFn = require('./core.get-iterator-method'); module.exports = function(iterable, entries, fn, that){ var iterFn = getIterFn(iterable) , f = ctx(fn, that, entries ? 2 : 1) , index = 0 , length, step, iterator; 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++){ entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]); } else for(iterator = iterFn.call(iterable); !(step = iterator.next()).done; ){ call(iterator, f, step.value, entries); } };
Version data entries
40 entries across 18 versions & 7 rubygems