Created
June 21, 2015 15:32
-
-
Save tit/0aab26c3b6ed49a1f6b8 to your computer and use it in GitHub Desktop.
Sleep in JS
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
Number.prototype.times = function (cb) { for (var i = 0; i < +this; i++) {cb(i)} } | |
function sleep(ms) {var date = Date.now(); while (Date.now() - date < 1000*ms) {} } | |
/* example use/* | |
10..times(function(i){sleep(1); console.log(i);}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment