Skip to content

Commit

Permalink
fixes #1320
Browse files Browse the repository at this point in the history
  • Loading branch information
petkaantonov committed Mar 3, 2017
1 parent c5b3ef3 commit 6bdc243
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,25 @@ var nodebackForPromise = require("./nodeback");
var errorObj = util.errorObj;
var tryCatch = util.tryCatch;
function check(self, executor) {
if (self == null || self.constructor !== Promise) {
throw new TypeError(CONSTRUCT_ERROR_INVOCATION);
}
if (typeof executor !== "function") {
throw new TypeError(FUNCTION_ERROR + util.classString(executor));
}
if (self.constructor !== Promise) {
throw new TypeError(CONSTRUCT_ERROR_INVOCATION);
}

}

function Promise(executor) {
if (executor !== INTERNAL) {
check(this, executor);
}
this._bitField = NO_STATE;
this._fulfillmentHandler0 = undefined;
this._rejectionHandler0 = undefined;
this._promise0 = undefined;
this._receiver0 = undefined;
if (executor !== INTERNAL) {
check(this, executor);
this._resolveFromExecutor(executor);
}
this._resolveFromExecutor(executor);
this._promiseCreated();
this._fireEvent("promiseCreated", this);
}
Expand Down Expand Up @@ -504,6 +505,7 @@ function(reason, synchronous, ignoreNonErrorWarnings) {
};

Promise.prototype._resolveFromExecutor = function (executor) {
if (executor === INTERNAL) return;
ASSERT(typeof executor === "function");
var promise = this;
this._captureStackTrace();
Expand Down

0 comments on commit 6bdc243

Please sign in to comment.