Comparing version 0.0.2 to 0.0.3
25
kew.js
@@ -65,3 +65,4 @@ function Promise(onSuccess, onFail) { | ||
Promise.prototype._chainPromise = function (promise) { | ||
if (this._hasData) promise.withInput(this._data) | ||
if (this._child) this._child._chainPromise(promise) | ||
else if (this._hasData) promise.withInput(this._data) | ||
else if (this._error) promise.withError(this._error) | ||
@@ -133,18 +134,21 @@ else if (!this._promises) this._promises = [promise] | ||
var counter = 0 | ||
var failed = false | ||
var finished = false | ||
var promise = new Promise() | ||
var counter = promises.length | ||
for (var i = 0; i < promises.length; i += 1) { | ||
if (!promises[i]._isPromise) outputs[i] = promises[i] | ||
else { | ||
counter += 1 | ||
if (!promises[i] || !promises[i]._isPromise) { | ||
outputs[i] = promises[i] | ||
counter -= 1 | ||
} else { | ||
promises[i].then(replaceEl.bind(null, outputs, i)) | ||
.then(function () { | ||
counter-- | ||
if (counter === 0) { | ||
if (!finished && counter === 0) { | ||
finished = true | ||
promise.resolve(outputs) | ||
} | ||
}, function (e) { | ||
if (!failed) { | ||
failed = true | ||
if (!finished) { | ||
finished = true | ||
promise.reject(e) | ||
@@ -156,2 +160,7 @@ } | ||
if (counter === 0) { | ||
finished = true | ||
promise.resolve(outputs) | ||
} | ||
return promise | ||
@@ -158,0 +167,0 @@ } |
{ | ||
"name": "kew" | ||
, "description": "kew?" | ||
, "version": "0.0.2" | ||
, "version": "0.0.3" | ||
, "homepage": "https://github.com/azulus/kew" | ||
@@ -6,0 +6,0 @@ , "authors": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5207
203