promise-timing-functions
v1.0.1
Published
Use setTimeout and requestAnimationFrame using ES2015 Promises and/or async/await
Downloads
1
Maintainers
Readme
Promise-Timing-Functions
Use setTimeout and requestAnimationFrame with ES2015 Promises and/or async/await
Installation
npm i promise-timing-functions
Usage
Importing
const { promiseSetTimeout, promiseRequestAnimationFrame } = require('promise-timing-functions')
promiseSetTimeOut
console.log(1)
await promiseSetTimeout(1000) // pause for 1000ms
console.log(2)
promiseRequestAnimationFrame
(async function loop() {
console.log(Math.random())
// infinite loop. perfect for animating objects on the page
await promiseRequestAnimationFrame()
loop()
})()