@whi/promise-timeout
v0.2.2
Published
A micro-package for scheduling a timeout rejection on a Promise
Downloads
96
Readme
new PromiseTimeout( executor, timeout )
This micro-package is intended to help with scheduling timeout rejection on a Promise.
Overview
Install
npm i @whi/promise-timeoutUsage
const { PromiseTimeout } = require('@whi/promise-timeout');
await new PromiseTimeout( (f,r) => {
}, 1000 );
// throw TimeoutErrorOptionally, attach timeout to the native Promise as a method so that you can add timeouts to
existing Promises.
require('@whi/promise-timeout').bindNative();
await Promise.timeout(
new Promise( () => null ), // Promise that will never settle
1000,
);
// throw TimeoutErrorAPI Reference
See docs/API.md
Contributing
See CONTRIBUTING.md
