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

Commit 481d5071 by Jan Aagaard Meier

Add support for calling promise.done with no arguments. Closes #2161

1 parent 0b9ddfa4
Showing with 7 additions and 0 deletions
# Next # Next
- [BUG] Fixed an issue with foreign key object syntax for hasOne and belongsTo - [BUG] Fixed an issue with foreign key object syntax for hasOne and belongsTo
- [FEATURE] Added `field` and `name` to the object form of foreign key definitions - [FEATURE] Added `field` and `name` to the object form of foreign key definitions
- [FEATURE] Added support for calling `Promise.done`, thus explicitly ending the promise chain by calling done with no arguments. Done with a function argument still continues the promise chain, to maintain BC.
#### Backwards compatability changes #### Backwards compatability changes
- The `fieldName` property, used in associations with a foreign key object `(A.hasMany(B, { foreignKey: { ... }})`, has been renamed to `name` to avoid confusion with `field`. - The `fieldName` property, used in associations with a foreign key object `(A.hasMany(B, { foreignKey: { ... }})`, has been renamed to `name` to avoid confusion with `field`.
......
...@@ -117,8 +117,14 @@ SequelizePromise.prototype.error = function(fct) { ...@@ -117,8 +117,14 @@ SequelizePromise.prototype.error = function(fct) {
* @alias complete * @alias complete
* @return this * @return this
*/ */
var bluebirdDone = Promise.prototype.done;
SequelizePromise.prototype.done = SequelizePromise.prototype.done =
SequelizePromise.prototype.complete = function(fct) { SequelizePromise.prototype.complete = function(fct) {
if (!fct) {
// If no callback is provided, map to the promise.done function, which explicitly ends a promise chain
return bluebirdDone.call(this);
}
if (fct.length > 2) { if (fct.length > 2) {
return this.spread(function() { return this.spread(function() {
fct.apply(null, [null].concat(Array.prototype.slice.call(arguments))); fct.apply(null, [null].concat(Array.prototype.slice.call(arguments)));
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!