diff options
Diffstat (limited to 'node_modules/bluebird/js/main/reduce.js')
-rw-r--r-- | node_modules/bluebird/js/main/reduce.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/node_modules/bluebird/js/main/reduce.js b/node_modules/bluebird/js/main/reduce.js index 319222012..1f92dafac 100644 --- a/node_modules/bluebird/js/main/reduce.js +++ b/node_modules/bluebird/js/main/reduce.js @@ -4,6 +4,7 @@ module.exports = function(Promise, apiRejection, tryConvertToPromise, INTERNAL) { +var getDomain = Promise._getDomain; var async = require("./async.js"); var util = require("./util.js"); var tryCatch = util.tryCatch; @@ -32,7 +33,8 @@ function ReductionPromiseArray(promises, fn, accum, _each) { } } if (!(isPromise || this._zerothIsAccum)) this._gotAccum = true; - this._callback = fn; + var domain = getDomain(); + this._callback = domain === null ? fn : domain.bind(fn); this._accum = accum; if (!rejected) async.invoke(init, this, undefined); } @@ -86,7 +88,7 @@ ReductionPromiseArray.prototype._promiseFulfilled = function (value, index) { if (!gotAccum) return; var callback = this._callback; - var receiver = this._promise._boundTo; + var receiver = this._promise._boundValue(); var ret; for (var i = this._reducingIndex; i < length; ++i) { |