right-now ![stable](https://camo.githubusercontent.com/cd290eab45c2e6b560791ced66e18d1639eea4a4274681afbaca425a0f650054/687474703a2f2f68756768736b2e6769746875622e696f2f73746162696c6974792d6261646765732f646973742f737461626c652e737667)
Get the quickest, most high-resolution timestamp possible in node or the browser.
Instead of returning the date, right-now
may use performance.now
, Date.now
, +new Date
or process.hrtime
to get a timestamp suitable for measuring intervals of time. Handy for both animation loops and precision benchmarking.
It's pretty small but saves me writing this boilerplate every time :)
Installation
npm install right-now
Usage
require('right-now')()
Returns a timestamp. In node, this uses process.hrtime
. In the browser, support for the following is checked in this order:
performance.now()
Date.now()
+new Date