• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"use strict";
2module.exports = function(Promise, INTERNAL) {
3var PromiseReduce = Promise.reduce;
4var PromiseAll = Promise.all;
5
6function promiseAllThis() {
7    return PromiseAll(this);
8}
9
10function PromiseMapSeries(promises, fn) {
11    return PromiseReduce(promises, fn, INTERNAL, INTERNAL);
12}
13
14Promise.prototype.each = function (fn) {
15    return PromiseReduce(this, fn, INTERNAL, 0)
16              ._then(promiseAllThis, undefined, undefined, this, undefined);
17};
18
19Promise.prototype.mapSeries = function (fn) {
20    return PromiseReduce(this, fn, INTERNAL, INTERNAL);
21};
22
23Promise.each = function (promises, fn) {
24    return PromiseReduce(promises, fn, INTERNAL, 0)
25              ._then(promiseAllThis, undefined, undefined, promises, undefined);
26};
27
28Promise.mapSeries = PromiseMapSeries;
29};
30
31