Skip to content

Instantly share code, notes, and snippets.

@jed
Last active Dec 20, 2015
Embed
What would you like to do?
returns unique timestamps, delays subsequent calls if called more than once per millisecond.
var then = Date.now()
function monotonicTimestamp(cb) {
var now = Date.now()
now > then
? setImmediate(cb, null, then = now)
: setTimeout(cb, then - now, null, ++then)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment