diff options
Diffstat (limited to 'node_modules/bluebird/js/main/map.js')
-rw-r--r-- | node_modules/bluebird/js/main/map.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/node_modules/bluebird/js/main/map.js b/node_modules/bluebird/js/main/map.js index 66a5b179c..2f40efd24 100644 --- a/node_modules/bluebird/js/main/map.js +++ b/node_modules/bluebird/js/main/map.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; @@ -14,7 +15,8 @@ var EMPTY_ARRAY = []; function MappingPromiseArray(promises, fn, limit, _filter) { this.constructor$(promises); this._promise._captureStackTrace(); - this._callback = fn; + var domain = getDomain(); + this._callback = domain === null ? fn : domain.bind(fn); this._preservedValues = _filter === INTERNAL ? new Array(this.length()) : null; @@ -49,7 +51,7 @@ MappingPromiseArray.prototype._promiseFulfilled = function (value, index) { if (preservedValues !== null) preservedValues[index] = value; var callback = this._callback; - var receiver = this._promise._boundTo; + var receiver = this._promise._boundValue(); this._promise._pushContext(); var ret = tryCatch(callback).call(receiver, value, index, length); this._promise._popContext(); |