monotonic-timestamp

Monotonically increasing timestamp.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
monotonic-timestamp
4340.0.98 years ago10 years agoMinified + gzip package size for monotonic-timestamp in KB

Readme

monotonic-timestamp
Monotonically increasing timestamp.

This is NOT a accurate representation of the time. Since js only measures time as ms, if you call Date.now() twice quickly, it's possible to get two identical time stamps.
monotonic-timestamp fixes that problem! (crudely)

Example

var timestamp = require('monotonic-timestamp')

console.log(timestamp())
console.log(timestamp())
console.log(timestamp())
console.log(timestamp())
console.log(timestamp())

subsequent calls to timestamp() are ALWAYS strictly ordered.

byte optimizations

My precious bytes! wasted on your timestamp!
pack it into a string!
timestamp().toString(36) 

if you want a constant-length string, you can use monotonic-timestamp-base36
of course, if you are using a binary protocol, it will be cheaper to use the float...

TODO

syncronize network time.

License

MIT