Comparing version 1.0.0 to 1.0.1
@@ -1,2 +0,2 @@ | ||
module.exports = now | ||
module.exports = Date.now || now | ||
@@ -3,0 +3,0 @@ function now() { |
{ | ||
"name": "date-now", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A requirable version of Date.now()", | ||
@@ -36,2 +36,7 @@ "keywords": [], | ||
}, | ||
"component": { | ||
"scripts": { | ||
"date-now/index.js": "index.js" | ||
} | ||
}, | ||
"testling": { | ||
@@ -38,0 +43,0 @@ "files": "test/*.js", |
@@ -7,2 +7,3 @@ # date-now | ||
A requirable version of Date.now() | ||
@@ -9,0 +10,0 @@ |
@@ -8,5 +8,7 @@ var test = require("tape") | ||
test("date", function (assert) { | ||
var before = new Date().getTime() | ||
var ts = now() | ||
var ts2 = Date.now() | ||
assert.equal(ts, ts2) | ||
var after = new Date().getTime() | ||
assert.ok(before <= ts) | ||
assert.ok(after >= ts) | ||
assert.end() | ||
@@ -16,15 +18,23 @@ }) | ||
test("seeded", function (assert) { | ||
var before = now() | ||
var time = seeded(40) | ||
var after = now() | ||
var bts = now() | ||
var ts = time() | ||
var ats = now() | ||
within(assert, time(), 40, 5) | ||
assert.ok(ts >= bts - before + 40) | ||
assert.ok(ts <= ats - after + 40) | ||
setTimeout(function () { | ||
within(assert, time(), 90, 10) | ||
var bts = now() | ||
var ts = time() | ||
var ats = now() | ||
assert.ok(ts >= bts - before + 40) | ||
assert.ok(ts <= ats - after + 40) | ||
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
5313
11
74
47