New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@js-util/promise-sleep

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@js-util/promise-sleep

Returns a promise, which resolve after the specified sleep itme (ms)

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Promise Sleep

Returns a promise, which resolve after the specified sleep itme (ms)

npm install

npm install --save @js-util/promise-sleep

Example usage

// Importing the module
const promiseSleep = require("@js-util/promise-sleep");

// Await sleep in ms
// 1000 ms -> 1 second
await promiseSleep(1000)

Its code

// Store a reference to the global setTimeout,
// in case it gets replaced (e.g. sinon.useFakeTimers())
const timeoutFunction = setTimeout;

/**
 * @param {Int} timeout in milliseconds to sleep by
 * @return a promise which resolves on timeout, returns no actual value
 */
function promiseSleep(timeout) {
    return new Promise((resolve) => {
        timeoutFunction(resolve, timeout);
    });
}

// Export the function
module.exports = promiseSleep;

Keywords

FAQs

Package last updated on 24 Sep 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc