Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrans committed Aug 24, 2013
1 parent 3192539 commit 4330aa7
Showing 1 changed file with 6 additions and 28 deletions.
34 changes: 6 additions & 28 deletions later.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ var Later = function(f) {
resolves.forEach(function(f) {
f(val);
});
} catch(e) {
return subpromises.forEach(function(p) {
p.reject && p.reject(e);
});
}
subpromises.forEach(function(p) {
p.resolve && p.resolve(val);
});
} catch(e) {}
});
}
};
Expand All @@ -30,17 +23,8 @@ var Later = function(f) {
promise.value = val;
promise.state = 'rejected';
setTimeout(function() {
try {
rejects.forEach(function(f) {
f(val);
});
} catch(e) {
return subpromises.forEach(function(p) {
p.reject && p.reject(e);
});
}
subpromises.forEach(function(p) {
p.resolve && p.resolve(val);
rejects.forEach(function(f) {
f(val);
});
});
}
Expand All @@ -56,15 +40,9 @@ var Later = function(f) {
if (typeof(reject) == 'function') {
rejects.push(reject);
}
var subpromise = {
then: function(resolve, reject) {
this.resolve = resolve;
this.reject = reject;
}
};

subpromises.push(subpromise);
return subpromise;
return Later(function(resolve, reject) {

});
},
state: 'pending',
value: undefined
Expand Down

0 comments on commit 4330aa7

Please sign in to comment.