@ljharb/now
The current time in milliseconds, from the most precise monotonic clock available (`performance.now` → `process.hrtime` → `Date.now` → `new Date().getTime()`), for measuring elapsed time.
Last updated 6 months ago by ljharb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @ljharb/now 
SYNC missed versions from official npm registry.

@ljharb/now Version Badge

github actions coverage License Downloads

npm badge

The current time, in milliseconds, from the most precise monotonic clock available - performance.now(), then process.hrtime(), then Date.now(), then new Date().getTime() (for ES3). Works in browsers and node, all the way back to ES3.

The returned value has an arbitrary origin and is only meaningful relative to another call: subtract two readings to get an elapsed duration, in milliseconds. Where the platform provides a monotonic clock (the first two tiers), it is unaffected by system clock changes.

Usage / Example

var now = require('@ljharb/now');
var assert = require('assert');

assert.equal(typeof now(), 'number');

var start = now();
// ... do some work ...
var elapsed = now() - start;

assert.equal(typeof elapsed, 'number');
assert.ok(elapsed >= 0);

Current Tags

  • 1.0.1                                ...           latest (6 months ago)

2 Versions

  • 1.0.1                                ...           6 months ago
  • 1.0.0                                ...           6 months ago
Maintainers (1)
Downloads
Total 6
Today 0
This Week 0
This Month 5
Last Day 0
Last Week 1
Last Month 1
Dependencies (3)
Dev Dependencies (20)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE