sleep for seconds
export in your deps.js
export {default as sleep} from 'https://deno.land/x/rmw_sleep@0.0.8/lib/sleep.js'
source code
export default (sec)=>
new Promise((resolve) => setTimeout(resolve, sec * 1000))
use example
coffeescript version
import sleep from './sleep.js'
do =>
n = 0
while ++n < 3
console.log new Date()
await sleep 1
javascript version
// Generated by CoffeeScript 2.5.1
import sleep from './sleep.js';
(async() => {
var n, results;
n = 0;
results = [];
while (++n < 3) {
console.log(new Date());
results.push((await sleep(1)));
}
return results;
})();
//# sourceMappingURL=sleep_test.js.map