MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / forEachRight

Function forEachRight

MathBox/mathbox-bundle.js:38458–38476  ·  view source on GitHub ↗

* This method is like `_.forEach` except that it iterates over elements * of a `collection` from right to left. * * @static * @memberOf _ * @alias eachRight * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @pa

(collection, callback, thisArg)

Source from the content-addressed store, hash-verified

38456 * // => logs each number from right to left and returns '3,2,1'
38457 */
38458 function forEachRight(collection, callback, thisArg) {
38459 var length = collection ? collection.length : 0;
38460 callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3);
38461 if (typeof length == 'number') {
38462 while (length--) {
38463 if (callback(collection[length], length, collection) === false) {
38464 break;
38465 }
38466 }
38467 } else {
38468 var props = keys(collection);
38469 length = props.length;
38470 forOwn(collection, function(value, key, collection) {
38471 key = props ? props[--length] : --length;
38472 return callback(collection[key], key, collection);
38473 });
38474 }
38475 return collection;
38476 }
38477
38478 /**
38479 * Creates an object composed of keys generated from the results of running

Callers 2

findLastFunction · 0.85
reduceRightFunction · 0.85

Calls 3

baseCreateCallbackFunction · 0.85
forOwnFunction · 0.85
callbackFunction · 0.70

Tested by

no test coverage detected