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 0.1.1 to 0.1.2

seed.js

2

package.json
{
"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)
}
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