2 ms·
Promise.withResolvers can fill this gap now (though it's not natively available in Node, yet): function sleep(ms) { const { promise, resolve } = Promise.
by M2Ys4U 3y ago
Promise.withResolvers can fill this gap now (though it's not natively available in Node, yet):
function sleep(ms) {
const { promise, resolve } = Promise.withResolvers();
return setTimeout(resolve, ms), promise;
}