Skip to content

Commit

Permalink
Add a few comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Twisol committed Jan 12, 2013
1 parent 32ef914 commit b7d0f9b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions when.js
Expand Up @@ -210,6 +210,8 @@ define(function () {


// Shunt a promise into the next turn of the event loop
// Could be made more efficient by pre-caching the results of
// shunt() for "resolve", "reject", and "progress".
function shunt(type) {
return function(value) {
var deferred = asap();
Expand Down Expand Up @@ -240,6 +242,7 @@ define(function () {
// register promise handlers
var promise = promiseFor(promiseOrValue);

// If we're not continuing an existing future computation, start one now.
if (!isPromise(promiseOrValue)) {
promise = promise.then(shunt('resolve'), shunt('reject'));
}
Expand Down

0 comments on commit b7d0f9b

Please sign in to comment.