Skip to content

Instantly share code, notes, and snippets.

Last active Dec 20, 2015
What would you like to do?
returns unique timestamps, delays subsequent calls if called more than once per millisecond.
var then =
function monotonicTimestamp(cb) {
var 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