1.0.1 • Published 5 years ago

promise-timing-functions v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

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()
})()