* 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)
| 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 |
no test coverage detected