You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

promise-resolve-timeout

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-resolve-timeout

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

2.0.1
latest
Source
npmnpm
Version published
Weekly downloads
5.4K
-3.67%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

promise

FAQs

Package last updated on 12 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts