# raf-iterator

> requestAnimationFrame as an async iterator

Latest version **1.1.0** (published 2024-10-10) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install raf-iterator
pnpm add raf-iterator
yarn add raf-iterator
bun add raf-iterator
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2024-10-10 |
| First published | 2018-10-16 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Renée Kooi |
| Maintainers | goto-bus-stop |
| Keywords | async, iterator, loop, raf, requestanimationframe |

## Links

- npm: https://www.npmjs.com/package/raf-iterator
- Repository: https://github.com/goto-bus-stop/raf-iterator
- Issues: https://github.com/goto-bus-stop/raf-iterator/issues
- npm.io page: https://npm.io/package/raf-iterator

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2024-10-10
- 1.0.0 — 2018-10-16

## README

# 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](#install) - [Usage](#usage) - [License: Apache-2.0](#license)

[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![standard][standard-image]][standard-url]

[npm-image]: https://img.shields.io/npm/v/raf-iterator.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/raf-iterator
[travis-image]: https://img.shields.io/travis/com/goto-bus-stop/raf-iterator.svg?style=flat-square
[travis-url]: https://travis-ci.com/goto-bus-stop/raf-iterator
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: http://npm.im/standard

## Install

```
npm install raf-iterator
```

## Usage

```js
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.

`break`ing from the loop prevents further animation frame requests.

## License

[Apache-2.0](LICENSE.md)

---
_Source: https://npm.io/package/raf-iterator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
