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

Commit 9e17971f by Mick Hansen

chore: add deprecation warnings to event emitter style callbacks, closes #2280

1 parent d6c9e0d1
Showing with 10 additions and 1 deletions
......@@ -3,7 +3,13 @@
var Promise = require('sequelize-bluebird')
, EventEmitter = require('events').EventEmitter
, proxyEventKeys = ['success', 'error', 'sql']
, Utils = require('./utils');
, Utils = require('./utils')
, seen = {}
, deprecated = function(message) {
if (seen[message]) return;
console.warn(message);
seen[message] = true;
};
/**
* A slightly modified version of bluebird promises. This means that, on top of the methods below, you can also call all the methods listed on the link below.
......@@ -75,6 +81,7 @@ SequelizePromise.prototype.emit = function(evt) {
*/
SequelizePromise.prototype.success =
SequelizePromise.prototype.ok = function(fct) {
deprecated('EventEmitter#success|ok is deprecated, please use promise-style instead.');
if (fct.length > 1) {
return this.spread(fct);
} else {
......@@ -100,6 +107,7 @@ SequelizePromise.prototype.ok = function(fct) {
SequelizePromise.prototype.failure =
SequelizePromise.prototype.fail =
SequelizePromise.prototype.error = function(fct) {
deprecated('EventEmitter#failure|fail|error is deprecated, please use promise-style instead.');
return this.then(null, fct);
};
......@@ -126,6 +134,7 @@ SequelizePromise.prototype.complete = function(fct) {
}
if (fct.length > 2) {
deprecated('EventEmitter#complete|done is deprecated, please use promise-style instead.');
return this.spread(function() {
fct.apply(null, [null].concat(Array.prototype.slice.call(arguments)));
}, fct);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!