1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | (function(define) { 'use strict';
|
7 | define(function() {
|
8 |
|
9 | return function fold(Promise) {
|
10 |
|
11 | Promise.prototype.fold = function(f, z) {
|
12 | var promise = this._beget();
|
13 |
|
14 | this._handler.fold(function(z, x, to) {
|
15 | Promise._handler(z).fold(function(x, z, to) {
|
16 | to.resolve(f.call(this, z, x));
|
17 | }, x, this, to);
|
18 | }, z, promise._handler.receiver, promise._handler);
|
19 |
|
20 | return promise;
|
21 | };
|
22 |
|
23 | return Promise;
|
24 | };
|
25 |
|
26 | });
|
27 | }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
|