Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

each.js 789B

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