npm.io
1.0.0 • Published 9 years ago

timedout-promise

Licence
MIT
Version
1.0.0
Deps
0
Vulns
0
Weekly
0

Timedout Promise

Utility function to set a timeout in milliseconds for promises.

Install

> yarn add timedout-promise

Usage

const timedoutPromise = require('timedout-promise');

timedoutPromise(1000, fetch('https://foo.bar/fiz'))
  .then((data) => console.log(`${data.length} loaded before 1000ms`))
  .catch(() => console.log('Timed out in 1000ms'))

Tests

> yarn test

Keywords