@jkroso/now

0.1.0 • Public • Published

now

get the highest resolution timestamp available x-browser

Getting Started

With component, packin or npm

$ {package mananger} install jkroso/now

then in your app:

var now = require('now')

API

now()

will return a timestamp relative to some arbitrary time in the past in milliseconds (ms). In older browsers that time happens to be the unix Epoch so is a lot bigger than it would be in a modern browser which will give you a time relative to page load.

now() // => 15.333000003010966

example

one possible use case is benchmarking

var start = now()
while (now() - start < 10) continue;
console.log('bench took %dms', start - now())
// => bench took 10ms

Running the example

$ npm install
$ make

Then open your browser to the ./example.html.

Note: these commands don't work on windows.

Package Sidebar

Install

npm i @jkroso/now

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • jkroso