@whi/promise-timeout

0.2.2 • Public • Published

new PromiseTimeout( executor, timeout )

This micro-package is intended to help with scheduling timeout rejection on a Promise.

Overview

Install

npm i @whi/promise-timeout

Usage

const { PromiseTimeout } = require('@whi/promise-timeout');

await new PromiseTimeout( (f,r) => {
}, 1000 );
// throw TimeoutError

Optionally, 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 TimeoutError

API Reference

See docs/API.md

Contributing

See CONTRIBUTING.md

Readme

Keywords

none

Package Sidebar

Install

npm i @whi/promise-timeout

Weekly Downloads

16

Version

0.2.2

License

ISC

Unpacked Size

4 kB

Total Files

4

Last publish

Collaborators

  • brisebom