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

sleep

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sleep - npm Package Compare versions

Comparing version 5.1.1 to 5.2.2

.travis.yml

4

package.json
{
"name": "sleep",
"version": "5.1.1",
"version": "5.2.2",
"main": "index.js",

@@ -27,5 +27,5 @@ "description": "Add sleep() and usleep() to nodejs",

"devDependencies": {
"mocha": "^3.0.2"
"mocha": "^4.0.1"
},
"gypfile": true
}

@@ -0,1 +1,4 @@

[![Build Status](https://travis-ci.org/erikdubbelboer/node-sleep.png?branch=master)](https://travis-ci.org/erikdubbelboer/node-sleep)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Ferikdubbelboer%2Fnode-sleep.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Ferikdubbelboer%2Fnode-sleep?ref=badge_shield)
sleep

@@ -8,4 +11,21 @@ =====

**These calls will block execution of all JavaScript by halting Node.js' event loop!**
These calls will block execution of all JavaScript by halting Node.js' event loop!
==================================================================================
Alternative
-----------
When using nodejs `9.3` or higher it's better to use [Atomics.wait](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait) which doesn't require compiling this C++
module.
The `sleep` and `msleep` functions can be implemented like this:
```js
function msleep(n) {
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, n);
}
function sleep(n) {
msleep(n*1000);
}
```
If you require `usleep` this module is still required.
Usage

@@ -23,1 +43,5 @@ -----

[2]: http://linux.die.net/man/3/usleep
## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Ferikdubbelboer%2Fnode-sleep.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Ferikdubbelboer%2Fnode-sleep?ref=badge_large)
/* globals describe, it */
var sleep = require('./');
var assert = require('assert');
var child_process = require('child_process');

@@ -8,3 +9,5 @@ function assertApproxEqual(val1, val2) {

var diff = Math.abs(val1 - val2);
assert.ok(diff <= epsilon);
if (diff > epsilon) {
assert.fail(diff, epsilon, 'wait was too short', '>');
}
}

@@ -34,2 +37,11 @@

});
it('works with child_process', function () {
var sleepTime = 1;
child_process.exec('echo', function (err, stdout, stderr) { });
var start = new Date();
sleep.sleep(sleepTime);
var end = new Date();
assertApproxEqual(end - start, sleepTime * 1000);
});
});

@@ -36,0 +48,0 @@

Sorry, the diff of this file is not supported yet

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