Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "date-now", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "A requirable version of Date.now()", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -21,2 +21,13 @@ # date-now | ||
## example of seed | ||
``` | ||
var now = require("date-now/seed")(timeStampFromServer) | ||
// ts is in "sync" with the seed value from the server | ||
// useful if your users have their local time being a few minutes | ||
// out of your server time. | ||
var ts = now() | ||
``` | ||
## Installation | ||
@@ -23,0 +34,0 @@ |
var test = require("tape") | ||
var setTimeout = require("timers").setTimeout | ||
var now = require("../index") | ||
var seeded = require("../seed") | ||
@@ -10,1 +13,17 @@ test("date", function (assert) { | ||
}) | ||
test("seeded", function (assert) { | ||
var time = seeded(40) | ||
var ts = time() | ||
within(assert, time(), 40, 5) | ||
setTimeout(function () { | ||
within(assert, time(), 90, 10) | ||
assert.end() | ||
}, 50) | ||
}) | ||
function within(assert, a, b, offset) { | ||
assert.ok(a + offset > b) | ||
assert.ok(a - offset < b) | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4752
10
53
46