You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Eugene Lazutkin edited this page Mar 19, 2016
·
3 revisions
A function that adapts any value to a promise. It detects foreign promises (then()-ables) and adapt to them correctly. As a result it returns a promise: either then()-able, or a resolved promise of a given type.
It takes up to two arguments:
value — a value to adapt.
Deferred — an optional constructor of deferred (realistically Deferred or FastDeferred), or a falsy value to use the standard Promise.
Example:
varwhen=require('heya-async/when');when(3).then(function(value){console.log('Is it 3? Yes:',value);returnvalue;});