{"_id":"request-animation-frames","_rev":"3-4e64d1d7d8c141f601560d90a610856d","name":"request-animation-frames","dist-tags":{"latest":"1.0.0"},"versions":{"0.0.0":{"name":"request-animation-frames","version":"0.0.0","description":"RAF","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/request-animation-frames.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava && tsd"},"keywords":["foo"],"devDependencies":{"ava":"^5.3.1","tsd":"^0.29.0","xo":"^0.56.0"},"types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/request-animation-frames/issues"},"homepage":"https://github.com/sindresorhus/request-animation-frames#readme","_id":"request-animation-frames@0.0.0","_nodeVersion":"20.9.0","_npmVersion":"9.2.0","dist":{"integrity":"sha512-KAN00AmeGKm0VEhDbAu5I8acqi8ejCQDzBOQaT3fNkdF2tZh43u1f0J+m1hG5uAslFhTvCc2dQUGnun2Edefkw==","shasum":"7f6ef981615603b6e725938a0adad8787296c5b6","tarball":"https://registry.npmjs.org/request-animation-frames/-/request-animation-frames-0.0.0.tgz","fileCount":5,"unpackedSize":4990,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDxSCTxmqOeEwyYXFHjoDZ3s2R6Ys9VmFMF1TlXRYLE0AIhAILLdJn6UGxe8mPSJkmcDevES4S6+KpEZ4js/cCkMpBK"}]},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/request-animation-frames_0.0.0_1700519138991_0.4666093089868608"},"_hasShrinkwrap":false},"0.1.0":{"name":"request-animation-frames","version":"0.1.0","description":"Use requestAnimationFrame as an async iterable, in any JavaScript environment","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/request-animation-frames.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava"},"keywords":["requestAnimationFrame","animation","frame","frames","raf","asynciterable","asynciterator","iterable","iterator","generator","async","performance","events","stream","loop","tick","game","ponyfill","polyfill"],"devDependencies":{"ava":"^5.3.1","xo":"^0.56.0"},"types":"./index.d.ts","gitHead":"819b3a3350c4c1b05992e04c7ba4176e49fcc9b1","bugs":{"url":"https://github.com/sindresorhus/request-animation-frames/issues"},"homepage":"https://github.com/sindresorhus/request-animation-frames#readme","_id":"request-animation-frames@0.1.0","_nodeVersion":"18.18.2","_npmVersion":"9.2.0","dist":{"integrity":"sha512-Kp0aqoTrky339FdyQRbThVrnlwshqDhq1qQbfm91ZWdIHkeWjtg4BJ+iAb/fcnVSjMuqvi1JQQHejIgXFKOPFQ==","shasum":"331af553b46c7234a3ed3e717f2e6bdff4cd4cba","tarball":"https://registry.npmjs.org/request-animation-frames/-/request-animation-frames-0.1.0.tgz","fileCount":5,"unpackedSize":4494,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCUo8ff7ea9PGRAAJ6iqgFWafpAODWHhj+hwpQfqjopyQIgbdxz7kcTXn2gGUHLbBm7+AMTfAupWYMYaqJmjK9ijfU="}]},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/request-animation-frames_0.1.0_1700564284338_0.9261850581474178"},"_hasShrinkwrap":false},"0.1.1":{"name":"request-animation-frames","version":"0.1.1","description":"Use requestAnimationFrame as an async iterable, in any JavaScript environment","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/request-animation-frames.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava"},"keywords":["requestAnimationFrame","animation","frame","frames","raf","asynciterable","asynciterator","iterable","iterator","generator","async","performance","events","stream","loop","tick","game","ponyfill","polyfill"],"devDependencies":{"ava":"^5.3.1","xo":"^0.56.0"},"types":"./index.d.ts","gitHead":"43806126c8d631b4f3ace612bf6d7b047b41224d","bugs":{"url":"https://github.com/sindresorhus/request-animation-frames/issues"},"homepage":"https://github.com/sindresorhus/request-animation-frames#readme","_id":"request-animation-frames@0.1.1","_nodeVersion":"18.18.2","_npmVersion":"9.2.0","dist":{"integrity":"sha512-5MMA+OUuvBBP3XJFQW8p/DPRCORP+ow1Mvr4m6yYptS2Zu6yB3xdcfBPmvhdulpQ/6wWn0uJQqslbkwzKt+ZjQ==","shasum":"634efbf9b375e4aa922656a1bc4c9c04341fa089","tarball":"https://registry.npmjs.org/request-animation-frames/-/request-animation-frames-0.1.1.tgz","fileCount":5,"unpackedSize":5141,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIE50cfAL3+35WlVh+ILZ+7nyxH44gh1DbiMsHISr2cruAiEA5RfMVuyD6DKGRhtciHh4dg7j4+SxV1/3ksZEylTxL5I="}]},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/request-animation-frames_0.1.1_1700601530881_0.7264045618007351"},"_hasShrinkwrap":false},"1.0.0":{"name":"request-animation-frames","version":"1.0.0","description":"Use requestAnimationFrame as an async iterable, in any JavaScript environment","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/request-animation-frames.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava"},"keywords":["requestAnimationFrame","animation","frame","frames","raf","asynciterable","asynciterator","iterable","iterator","generator","async","performance","events","stream","loop","tick","game","ponyfill","polyfill"],"devDependencies":{"ava":"^5.3.1","xo":"^0.56.0"},"types":"./index.d.ts","gitHead":"637bf83b014303607b1c5e68772fd6a4bb666fa8","bugs":{"url":"https://github.com/sindresorhus/request-animation-frames/issues"},"homepage":"https://github.com/sindresorhus/request-animation-frames#readme","_id":"request-animation-frames@1.0.0","_nodeVersion":"21.5.0","_npmVersion":"9.2.0","dist":{"integrity":"sha512-THOhYcI5OUY9M6IsmxW24/IItGwEUncfujiqwVF3DYxSxuEfrv1Z74KQfwAcH0zcGgzI5hgHtJEslPPhdRrJ5w==","shasum":"91b0b8eb22fd6c0f74d315d8d68b1cfd4e585189","tarball":"https://registry.npmjs.org/request-animation-frames/-/request-animation-frames-1.0.0.tgz","fileCount":5,"unpackedSize":5113,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGOLC9SA0rPanBUNIg28ReUxyGIuZCEno06aSnPtoF1nAiBE4NtTd6BdTARFfvKjPO6EXlxucxSlKQQDqqaFt4c+DA=="}]},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/request-animation-frames_1.0.0_1704579265614_0.523494490228223"},"_hasShrinkwrap":false}},"time":{"created":"2023-11-20T22:25:38.990Z","0.0.0":"2023-11-20T22:25:39.187Z","modified":"2024-01-06T22:14:26.008Z","0.1.0":"2023-11-21T10:58:04.518Z","0.1.1":"2023-11-21T21:18:51.229Z","1.0.0":"2024-01-06T22:14:25.796Z"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"description":"Use requestAnimationFrame as an async iterable, in any JavaScript environment","homepage":"https://github.com/sindresorhus/request-animation-frames#readme","keywords":["requestAnimationFrame","animation","frame","frames","raf","asynciterable","asynciterator","iterable","iterator","generator","async","performance","events","stream","loop","tick","game","ponyfill","polyfill"],"repository":{"type":"git","url":"git+https://github.com/sindresorhus/request-animation-frames.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"bugs":{"url":"https://github.com/sindresorhus/request-animation-frames/issues"},"license":"MIT","readme":"# request-animation-frames\n\n> Use [`requestAnimationFrame`](https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame) as an async iterable, in any JavaScript environment\n\nThis package [ponyfills](https://ponyfill.com) `requestAnimationFrame` internally when not available, so it works in any JavaScript environment.\n\n## Install\n\n```sh\nnpm install request-animation-frames\n```\n\n## Usage\n\n```js\nimport requestAnimationFrames from 'request-animation-frames';\n\nfor await (const timestamp of requestAnimationFrames()) {\n\tconsole.log('Animation frame timestamp:', timestamp);\n\tdrawVisualization();\n}\n```\n\n## API\n\n### requestAnimationFrames()\n\nReturns an [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols) that yields animation frame [timestamps](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp).\n\nThe first timestamp is yielded right away for easier setup.\n\n## FAQ\n\n### How do I stop the iteration?\n\nSimply `return` or `break` in the loop body.\n\n### How do I stop the iteration from the outside?\n\n```js\nimport requestAnimationFrames from 'request-animation-frames';\n\nlet shouldStop = false;\n\n(async () => {\n\tfor await (const timestamp of requestAnimationFrames()) {\n\t\tif (shouldStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tconsole.log('Animation frame timestamp:', timestamp);\n\t}\n})();\n\nsetTimeout(() => {\n\tshouldStop = true;\n}, 10000);\n```\n\n## Related\n\n- [dom-mutations](https://github.com/sindresorhus/dom-mutations) - Observe changes to the DOM using an async iterable\n","readmeFilename":"readme.md"}