raf-iterator
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

raf-iterator

requestAnimationFrame as an async iterator

Async iterators are very new and work on these platforms (non exhaustive):

  • Firefox 60+
  • Chrome 68+
  • Safari 12
  • Node 10+

Install - Usage - License: Apache-2.0

npm travis standard

Install

npm install raf-iterator

Usage

const rafIterator = require('raf-iterator')

for await (const tick of rafIterator()) {
  draw(tick)
  if (ended) {
    break
  }
}

API

rafIterator()

Returns an Async Iterator that can be used in a for await loop. Each iteration yields an incrementing tick integer. Iterations occur at the speed of requestAnimationFrame ticks, about 60fps.

breaking from the loop prevents further animation frame requests.

License

Apache-2.0

Dependencies (0)

    Dev Dependencies (6)

    Package Sidebar

    Install

    npm i raf-iterator

    Weekly Downloads

    0

    Version

    1.1.0

    License

    Apache-2.0

    Unpacked Size

    6.24 kB

    Total Files

    10

    Last publish

    Collaborators

    • goto-bus-stop