@prelude/function
Version:
Function module.
16 lines • 381 B
JavaScript
const timeout = (wait, f, g) => new Promise((resolve, reject) => {
const id = setTimeout(() => {
try {
resolve(g());
}
catch (err) {
reject(err);
}
}, wait);
f()
.finally(() => clearTimeout(id))
.then(resolve)
.catch(reject);
});
export default timeout;
//# sourceMappingURL=timeout.js.map