Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

date-now

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-now - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

component.json

2

index.js

@@ -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)
}
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