The Promise based setTimeout
and setImmediate
for the modern browsers and node.
stop.js
change to use milliseconds
as default unit. #1
In ES7 async
/await
is awesome, but that only supported with Promise.
npm i --save stop.js
Includes babel-polyfill
before use async
and await
console.log(1)
setTimeout(()=>{
console.log(2) // slow than 5 secs
}, 5000)
import stop from 'stop.js'
async function asyncFunc() {
console.log(1)
await stop(5000)
console.log(2) // slow than 5 secs
}
asyncFunc()
0
is default, it'll call the YuzuJS/setImmediate
library
console.log(1)
setImmediate(()=>{
console.log(2)
})
same as
console.log(1)
await stop(0)
console.log(2)
or pass nothing
console.log(1)
await stop()
console.log(2)