Urara-Blog/node_modules/.pnpm-store/v3/files/3e/8c6f057d24b1679677b0f03e082fb0082d46b785d4a6102cd4e5b625006e01974b43bc7491ab8017c539aa2bb5822c92241b9d4cb75e99e8631ca914408c0c
2022-08-14 01:14:53 +08:00

31 lines
924 B
Text

var arrayEachRight = require('./_arrayEachRight'),
baseEachRight = require('./_baseEachRight'),
castFunction = require('./_castFunction'),
isArray = require('./isArray');
/**
* This method is like `_.forEach` except that it iterates over elements of
* `collection` from right to left.
*
* @static
* @memberOf _
* @since 2.0.0
* @alias eachRight
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Array|Object} Returns `collection`.
* @see _.forEach
* @example
*
* _.forEachRight([1, 2], function(value) {
* console.log(value);
* });
* // => Logs `2` then `1`.
*/
function forEachRight(collection, iteratee) {
var func = isArray(collection) ? arrayEachRight : baseEachRight;
return func(collection, castFunction(iteratee));
}
module.exports = forEachRight;