1'use strict'; 2 3Object.defineProperty(exports, "__esModule", { 4 value: true 5}); 6exports.default = reduceRight; 7 8var _reduce = require('./reduce.js'); 9 10var _reduce2 = _interopRequireDefault(_reduce); 11 12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 13 14/** 15 * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order. 16 * 17 * @name reduceRight 18 * @static 19 * @memberOf module:Collections 20 * @method 21 * @see [async.reduce]{@link module:Collections.reduce} 22 * @alias foldr 23 * @category Collection 24 * @param {Array} array - A collection to iterate over. 25 * @param {*} memo - The initial state of the reduction. 26 * @param {AsyncFunction} iteratee - A function applied to each item in the 27 * array to produce the next step in the reduction. 28 * The `iteratee` should complete with the next state of the reduction. 29 * If the iteratee completes with an error, the reduction is stopped and the 30 * main `callback` is immediately called with the error. 31 * Invoked with (memo, item, callback). 32 * @param {Function} [callback] - A callback which is called after all the 33 * `iteratee` functions have finished. Result is the reduced value. Invoked with 34 * (err, result). 35 * @returns {Promise} a promise, if no callback is passed 36 */ 37function reduceRight(array, memo, iteratee, callback) { 38 var reversed = [...array].reverse(); 39 return (0, _reduce2.default)(reversed, memo, iteratee, callback); 40} 41module.exports = exports['default'];