diff options
Diffstat (limited to 'lib/reduceright/index.js')
-rw-r--r-- | lib/reduceright/index.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/reduceright/index.js b/lib/reduceright/index.js new file mode 100644 index 0000000..2e86c1e --- /dev/null +++ b/lib/reduceright/index.js @@ -0,0 +1,10 @@ +'use strict'; + +var map = require('async.util.map'); +var reduce = require('async.reduce'); +var identity = require('async.util.identity'); + +module.exports = function reduceRight (arr, memo, iterator, cb) { + var reversed = map(arr, identity).reverse(); + reduce(reversed, memo, iterator, cb); +}; |