mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Bump to v3.0.0.
This commit is contained in:
29
collection/forEachRight.js
Normal file
29
collection/forEachRight.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import arrayEachRight from '../internal/arrayEachRight';
|
||||
import baseEachRight from '../internal/baseEachRight';
|
||||
import bindCallback from '../internal/bindCallback';
|
||||
import isArray from '../lang/isArray';
|
||||
|
||||
/**
|
||||
* This method is like `_.forEach` except that it iterates over elements of
|
||||
* `collection` from right to left.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @alias eachRight
|
||||
* @category Collection
|
||||
* @param {Array|Object|string} collection The collection to iterate over.
|
||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
||||
* @returns {Array|Object|string} Returns `collection`.
|
||||
* @example
|
||||
*
|
||||
* _([1, 2, 3]).forEachRight(function(n) { console.log(n); }).join(',');
|
||||
* // => logs each value from right to left and returns the array
|
||||
*/
|
||||
function forEachRight(collection, iteratee, thisArg) {
|
||||
return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
|
||||
? arrayEachRight(collection, iteratee)
|
||||
: baseEachRight(collection, bindCallback(iteratee, thisArg, 3));
|
||||
}
|
||||
|
||||
export default forEachRight;
|
||||
Reference in New Issue
Block a user