Permalink
Browse files

expose Promise#fulfillment

  • Loading branch information...
1 parent ef29cf9 commit 3b83602f2c8381f2d98051bb22819230430b62ff @marcuswestin committed May 30, 2013
Showing with 5 additions and 5 deletions.
  1. +5 −5 Promise.js
View
@@ -7,20 +7,20 @@ var Class = require('./Class'),
module.exports = Class(function() {
this.init = function(callback) {
this._dependants = []
- this._fulfillment = null
+ this.fulfillment = null
if (callback) { this.add(callback) }
}
this.add = function(callback) {
- if (this._fulfillment) { callback.apply(this, this._fulfillment) }
+ if (this.fulfillment) { callback.apply(this, this.fulfillment) }
else { this._dependants.push(callback) }
return this
}
this.fulfill = function(/* arg1, arg2, ...*/) {
- if (this._fulfillment) { throw new Error('Promise fulfilled twice') }
- this._fulfillment = slice(arguments)
- each(this._dependants, invokeWith.apply(this, this._fulfillment))
+ if (this.fulfillment) { throw new Error('Promise fulfilled twice') }
+ this.fulfillment = slice(arguments)
+ each(this._dependants, invokeWith.apply(this, this.fulfillment))
delete this._dependants
return this
}

0 comments on commit 3b83602

Please sign in to comment.