main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
922 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import arrayEachRight from './_arrayEachRight.js';
|
---|
| 2 | import baseEachRight from './_baseEachRight.js';
|
---|
| 3 | import castFunction from './_castFunction.js';
|
---|
| 4 | import isArray from './isArray.js';
|
---|
| 5 |
|
---|
| 6 | /**
|
---|
| 7 | * This method is like `_.forEach` except that it iterates over elements of
|
---|
| 8 | * `collection` from right to left.
|
---|
| 9 | *
|
---|
| 10 | * @static
|
---|
| 11 | * @memberOf _
|
---|
| 12 | * @since 2.0.0
|
---|
| 13 | * @alias eachRight
|
---|
| 14 | * @category Collection
|
---|
| 15 | * @param {Array|Object} collection The collection to iterate over.
|
---|
| 16 | * @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
---|
| 17 | * @returns {Array|Object} Returns `collection`.
|
---|
| 18 | * @see _.forEach
|
---|
| 19 | * @example
|
---|
| 20 | *
|
---|
| 21 | * _.forEachRight([1, 2], function(value) {
|
---|
| 22 | * console.log(value);
|
---|
| 23 | * });
|
---|
| 24 | * // => Logs `2` then `1`.
|
---|
| 25 | */
|
---|
| 26 | function forEachRight(collection, iteratee) {
|
---|
| 27 | var func = isArray(collection) ? arrayEachRight : baseEachRight;
|
---|
| 28 | return func(collection, castFunction(iteratee));
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | export default forEachRight;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.