A promise that resolves after a delay.

Jan-Ivar Bruaroey jib at mozilla.com
Fri Feb 5 00:20:13 UTC 2016


On 2/3/16 11:39 PM, Bob Myers wrote:
> Promise.resolve(42) . then(wait(1000)) . then( /* cb */);

With ES6 I prefer the straightforward:

     var wait = ms => new Promise(resolve => setTimeout(resolve, ms));

     Promise.resolve(42) . then(() => wait(1000)).then(() => { /* cb */ });

  Too simple to standardize IMHO.

.: Jan-Ivar :.



More information about the es-discuss mailing list