source: trip-planner-front/node_modules/async/foldr.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

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