Comparing version 5.2.2 to 5.2.3
{ | ||
"name": "sleep", | ||
"version": "5.2.2", | ||
"version": "5.2.3", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "description": "Add sleep() and usleep() to nodejs", |
[![Build Status](https://travis-ci.org/erikdubbelboer/node-sleep.png?branch=master)](https://travis-ci.org/erikdubbelboer/node-sleep) | ||
[![Build status](https://ci.appveyor.com/api/projects/status/09kubqqykjaxdrab?svg=true)](https://ci.appveyor.com/project/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) | ||
@@ -3,0 +4,0 @@ |
12
test.js
@@ -7,6 +7,10 @@ /* globals describe, it */ | ||
function assertApproxEqual(val1, val2) { | ||
var epsilon = 5; // we require accuracy to the nearest N millisecond | ||
var diff = Math.abs(val1 - val2); | ||
// We require accuracy to the nearest N millisecond. | ||
// Windows Sleep is not super accurate (depends on scheduling policy) so use a high value. | ||
var epsilon = 100; | ||
var diff = val1 - val2; | ||
if (diff > epsilon) { | ||
assert.fail(diff, epsilon, 'wait was too short', '>'); | ||
assert.fail(diff, epsilon, 'wait was too long'); | ||
} else if (diff < -epsilon) { | ||
assert.fail(diff, epsilon, 'wait was too short'); | ||
} | ||
@@ -50,3 +54,3 @@ } | ||
it('works for values smaller than a second', function () { | ||
var sleepTime = 30; | ||
var sleepTime = 250; | ||
var start = new Date(); | ||
@@ -53,0 +57,0 @@ sleep.usleep(sleepTime); |
Sorry, the diff of this file is not supported yet
9398
9
93
47