basant307/AI_Governance_Project
048
1'use strict';2 3Object.defineProperty(exports, "__esModule", {4 value: true5});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 reduceRight18 * @static19 * @memberOf module:Collections20 * @method21 * @see [async.reduce]{@link module:Collections.reduce}22 * @alias foldr23 * @category Collection24 * @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 the27 * 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 the30 * 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 the33 * `iteratee` functions have finished. Result is the reduced value. Invoked with34 * (err, result).35 * @returns {Promise} a promise, if no callback is passed36 */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;