laissez-faire
Advanced tools
Comparing version 0.6.2 to 0.6.3
{ | ||
"name": "laissez-faire", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"description": "A promise implementation. Simple and fast", | ||
@@ -16,3 +16,3 @@ "main": "src/index.js", | ||
}, | ||
"scripts" : { | ||
"scripts": { | ||
"build": "node ./glue.js", | ||
@@ -19,0 +19,0 @@ "test": "node tests/" |
@@ -8,5 +8,3 @@ exports = module.exports = Promise | ||
*/ | ||
function Promise () { | ||
this.children = [] | ||
} | ||
function Promise () {this.length = 0} | ||
@@ -129,4 +127,4 @@ /** | ||
proto.then = function(done, fail) { | ||
var thenPromise | ||
this.children.push(thenPromise = new Promise) | ||
var thenPromise | ||
this[this.length++] = (thenPromise = new Promise) | ||
thenPromise._success = done | ||
@@ -146,3 +144,3 @@ thenPromise._fail = fail | ||
// Queue a sudo-promise capable of throwing errors | ||
this.children.push({ | ||
this[this.length++] = { | ||
// Handlers are bound to the assignment properties since these aren't run inside a try catch. Having no handlers is fine, the values will just pass straight through to the resolvers. | ||
@@ -152,3 +150,3 @@ resolve: done || noop, | ||
reject: fail || function (e) { throw e } | ||
}) | ||
} | ||
return this | ||
@@ -247,5 +245,5 @@ } | ||
// Propagate the value to any queued promises. | ||
var children = this.children, child, i = 0 | ||
var child, i = 0 | ||
// Use a forward loop to maintain insertion order | ||
while (child = children[i++]) { | ||
while (child = this[i++]) { | ||
if (child._success) propagate(child, child._success, value) | ||
@@ -280,8 +278,8 @@ else child.resolve(value) | ||
var children = this.children, i = 0, child | ||
if (child = children[i]) { | ||
var i = 0, child | ||
if (child = this[i]) { | ||
do { | ||
if (child._fail) propagate(child, child._fail, e) | ||
else child.reject(e) | ||
} while (child = children[++i]) | ||
} while (child = this[++i]) | ||
} | ||
@@ -288,0 +286,0 @@ else { |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
26254
309