Likely this would be more convincing without a bug. Here is the correct
wait function:
let wait = (ms, cancel = new Promise(() => {})) => {
let id, both = x => [x, x];
cancel.then(...both(() => clearTimeout(id)));
return Promise.race([new Promise(resolve => id = setTimeout(resolve,
ms)), cancel]);
};
For caller flexibility, we want to cancel on any activity of the cancel
promise, which would have been more apparent in an example that actually
relied on clearTimeout working. Fiddle updated. PTAL!
.: Jan-Ivar :.
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss