🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

thread-sleep

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

thread-sleep

A module for when you just need node to back off for a few milliseconds

2.2.0
latest
Source
npm
Version published
Weekly downloads
2.9K
-66.31%
Maintainers
2
Weekly downloads
 
Created
Source

thread-sleep

A native module for when you just need node to back off for a few milliseconds. It effectively pauses the current thread. It may be woken early if an interupt is fired, so it should work pretty well for busy waiting scenarios where you want to check something every few hunderd milliseconds.

Linux and Mac Build Status Windows Build Status Dependency Status NPM version

Installation

npm install thread-sleep

This module uses node-pre-gyp so it should install even without a compiler in most environments. If you run into any problems, please open an issue with the full npm log, and a description of what operating system you use.

Usage

var sleep = require('thread-sleep');

var start = Date.now();
var res = sleep(1000);
var end = Date.now();
// res is the actual time that we slept for
console.log(res + ' ~= ' + (end - start) + ' ~= 1000');
// tested on osx and resulted in => 1005 ~= 1010 ~= 1000

License

MIT

Keywords

sleep

FAQs

Package last updated on 17 Mar 2019

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