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