promise-resolve-timeout
Create a Promise which will resolve with the provided value after a timeout.
Last updated a year ago by fabiospampinato .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install promise-resolve-timeout 
SYNC missed versions from official npm registry.

Promise Resolve Timeout

Create a Promise which will resolve with the provided value after a timeout.

Install

npm install promise-resolve-timeout

Usage

If the passed value is a function it will be called and its return value will be the resolved value, otherwise the passed value is the resolved value.

import resolveTimeout from 'promise-resolve-timeout';

// Defaulting to a default value when racing promises

Promise.race ([
  resolveTimeout ( 1000, false ), // Resolving after 1000ms
  resolveTimeout ( 5000, () => 'foo' ), // Resolving after 5000ms
  new Promise ( () => {
    // Something...
  });
]);

// Delaying

resolveTimeout ( 1000 ) // Waiting 1000ms
  .then ( () => {
    // Something...
  });

License

MIT © Fabio Spampinato

Current Tags

  • 2.0.1                                ...           latest (a year ago)

6 Versions

  • 2.0.1                                ...           a year ago
  • 2.0.0                                ...           4 years ago
  • 1.2.1                                ...           6 years ago
  • 1.2.0                                ...           7 years ago
  • 1.1.0                                ...           7 years ago
  • 1.0.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 5
Last Day 0
Last Week 5
Last Month 1
Dependencies (0)
None
Dev Dependencies (3)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |