Projekt

Obecné

Profil

Stáhnout (1.5 KB) Statistiky
| Větev: | Revize:
1
'use strict';
2

    
3
Object.defineProperty(exports, "__esModule", {
4
  value: true
5
});
6
exports.default = reduceRight;
7

    
8
var _reduce = require('./reduce');
9

    
10
var _reduce2 = _interopRequireDefault(_reduce);
11

    
12
var _slice = require('./internal/slice');
13

    
14
var _slice2 = _interopRequireDefault(_slice);
15

    
16
function _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
 */
40
function reduceRight(array, memo, iteratee, callback) {
41
  var reversed = (0, _slice2.default)(array).reverse();
42
  (0, _reduce2.default)(reversed, memo, iteratee, callback);
43
}
44
module.exports = exports['default'];
(48-48/105)