不要怂,就是干,撸起袖子干!

Commit 387abfa7 by Jan Aagaard Meier

Forgot to copy-pasta a helper function from bluebird

1 parent f3711679
Showing with 24 additions and 19 deletions
...@@ -101,32 +101,32 @@ SequelizePromise.method = function (fn) { ...@@ -101,32 +101,32 @@ SequelizePromise.method = function (fn) {
}; };
SequelizePromise.prototype._resolveFromSyncValue = function(value) { SequelizePromise.prototype._resolveFromSyncValue = function(value) {
if (value && value.hasOwnProperty('e')) { if (value && value.hasOwnProperty('e')) {
this._cleanValues(); this._cleanValues();
this._setRejected(); this._setRejected();
this._settledValue = value.e; this._settledValue = value.e;
this._ensurePossibleRejectionHandled(); this._ensurePossibleRejectionHandled();
}
else {
var maybePromise = Promise._cast(value, void 0);
if (maybePromise instanceof Promise || maybePromise instanceof SequelizePromise) {
this._follow(maybePromise);
} }
else { else {
var maybePromise = Promise._cast(value, void 0); this._cleanValues();
if (maybePromise instanceof Promise || maybePromise instanceof SequelizePromise) { this._setFulfilled();
this._follow(maybePromise); this._settledValue = value;
}
else {
this._cleanValues();
this._setFulfilled();
this._settledValue = value;
}
} }
}
}; };
SequelizePromise.attempt = SequelizePromise.try = function (fn, args, ctx) { SequelizePromise.attempt = SequelizePromise.try = function (fn, args, ctx) {
var value = tryCatchApply(fn, args, ctx) var value = tryCatchApply(fn, args, ctx)
var ret = new SequelizePromise(INTERNAL); var ret = new SequelizePromise(INTERNAL);
ret._setTrace(void 0); ret._setTrace(void 0);
ret._resolveFromSyncValue(value); ret._resolveFromSyncValue(value);
return ret; return ret;
}; };
// Need to hack resolve cause we can't hack all directrly // Need to hack resolve cause we can't hack all directrly
...@@ -414,4 +414,8 @@ function tryCatchApply(fn, args, receiver) { ...@@ -414,4 +414,8 @@ function tryCatchApply(fn, args, receiver) {
} }
} }
function asString(val) {
return typeof val === "string" ? val : ("" + val);
}
module.exports = SequelizePromise; module.exports = SequelizePromise;
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!