0.1.0 • Published 8 years ago

@jkroso/now v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 years ago

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.