1.0.0 • Published 7 years ago

timedout-promise v1.0.0

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

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