Last active
December 20, 2015 00:59
-
-
Save jed/6046015 to your computer and use it in GitHub Desktop.
returns unique timestamps, delays subsequent calls if called more than once per millisecond.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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