stop.js
v0.2.3
Published
The Promise base setTimeout, reduce your callback
Downloads
2
Maintainers
Readme
Stop.js
The Promise based setTimeout
and setImmediate
for the modern browsers and node.
‼️Important
stop.js
change to use milliseconds
as default unit. #1
Browser Supported
Why
In ES7 async
/await
is awesome, but that only supported with Promise.
Installation
npm i --save stop.js
Includes babel-polyfill
before use async
and await
Before
console.log(1)
setTimeout(()=>{
console.log(2) // slow than 5 secs
}, 5000)
After
import stop from 'stop.js'
async function asyncFunc() {
console.log(1)
await stop(5000)
console.log(2) // slow than 5 secs
}
asyncFunc()
setImmediate
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)