sleep.js

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);})
Sleep function in JavaScript

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.