Version 1
[yaffs-website] / node_modules / uncss / node_modules / lodash / forEachRight.js
1 var arrayEachRight = require('./internal/arrayEachRight'),
2     baseEachRight = require('./internal/baseEachRight'),
3     isArray = require('./isArray'),
4     toFunction = require('./internal/toFunction');
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  * @alias eachRight
13  * @category Collection
14  * @param {Array|Object} collection The collection to iterate over.
15  * @param {Function} [iteratee=_.identity] The function invoked per iteration.
16  * @returns {Array|Object} Returns `collection`.
17  * @example
18  *
19  * _.forEachRight([1, 2], function(value) {
20  *   console.log(value);
21  * });
22  * // => logs `2` then `1`
23  */
24 function forEachRight(collection, iteratee) {
25   return (typeof iteratee == 'function' && isArray(collection))
26     ? arrayEachRight(collection, iteratee)
27     : baseEachRight(collection, toFunction(iteratee));
28 }
29
30 module.exports = forEachRight;