Skip to content

Commit

Permalink
Replaced several Array.prototype.slice.call() calls with Array.protot…
Browse files Browse the repository at this point in the history
…ype.unshift.call()

Acts in pretty much the same manor just a bit more elegant
  • Loading branch information
tj authored and ry committed Dec 18, 2009
1 parent 7873639 commit f3b0cef
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,25 +248,22 @@ process.Promise.prototype.cancel = function() {
};

process.Promise.prototype.emitCancel = function() {
var args = Array.prototype.slice.call(arguments);
args.unshift('cancel');
this.emit.apply(this, args);
Array.prototype.unshift.call(arguments, 'cancel')
this.emit.apply(this, arguments);
};

process.Promise.prototype.emitSuccess = function() {
if (this.hasFired) return;
var args = Array.prototype.slice.call(arguments);
args.unshift('success');
this.hasFired = true;
this.emit.apply(this, args);
Array.prototype.unshift.call(arguments, 'success')
this.emit.apply(this, arguments);
};

process.Promise.prototype.emitError = function() {
if (this.hasFired) return;
var args = Array.prototype.slice.call(arguments);
args.unshift('error');
this.hasFired = true;
this.emit.apply(this, args);
Array.prototype.unshift.call(arguments, 'error')
this.emit.apply(this, arguments);
};

process.Promise.prototype.addCallback = function (listener) {
Expand Down

0 comments on commit f3b0cef

Please sign in to comment.