{"_id":"@repeaterjs/repeater","_rev":"4330763","name":"@repeaterjs/repeater","description":"The missing constructor function for creating safe async iterators","dist-tags":{"beta":"3.0.0-beta.1","latest":"3.0.6"},"maintainers":[{"name":"brainkim","email":"briankimpossible@gmail.com"}],"time":{"modified":"2026-04-07T23:54:21.000Z","created":"2019-08-22T03:01:47.957Z","3.0.6":"2024-05-08T19:58:51.835Z","3.0.5":"2023-11-07T20:06:41.800Z","3.0.4":"2020-09-02T21:05:51.651Z","3.0.3":"2020-08-03T18:47:30.841Z","3.0.2":"2020-08-03T18:42:32.804Z","3.0.1":"2019-11-10T14:36:09.699Z","3.0.0":"2019-11-10T12:38:10.555Z","3.0.0-beta.1":"2019-10-28T03:04:35.235Z","2.0.0":"2019-08-24T21:01:12.646Z","1.0.0":"2019-08-22T03:01:47.957Z"},"users":{},"repository":{"type":"git","url":"https://github.com/repeaterjs/repeater","directory":"packages/repeater"},"versions":{"3.0.6":{"name":"@repeaterjs/repeater","version":"3.0.6","description":"The missing constructor function for creating safe async iterators","repository":{"type":"git","url":"https://github.com/repeaterjs/repeater","directory":"packages/repeater"},"license":"MIT","type":"module","main":"cjs/repeater.js","module":"repeater.js","types":"repeater.d.ts","exports":{".":{"require":{"types":"./cjs/repeater.d.ts","default":"./cjs/repeater.js"},"types":"./repeater.d.ts","default":"./repeater.js"}},"scripts":{"prebuild":"yarn run clean","build":"rollup -c ./rollup.config.js","clean":"shx rm -rf cjs dist repeater.js *.d.ts *.js.map","lint":"eslint --ext ts src","prepublishOnly":"yarn run test && yarn run build","test":"jest --config ./jest.config.cjs --rootDir ./ --color"},"devDependencies":{"@types/jest":"^26.0.7","@typescript-eslint/eslint-plugin":"^3.7.1","@typescript-eslint/parser":"^3.7.1","eslint":"^7.5.0","eslint-config-prettier":"^6.4.0","eslint-config-recommended-plus-types":"^1.0.0","eslint-plugin-jest":"^23.20.0","eslint-plugin-prettier":"^3.1.4","jest":"^26.2.1","magic-string":"^0.25.7","prettier":"^2.0.5","rollup":"^2.23.0","rollup-plugin-typescript2":"^0.27.1","shx":"^0.3.2","ts-jest":"^26.1.4","ts-transform-import-path-rewrite":"^0.2.1","typescript":"^3.9.7"},"publishConfig":{"access":"public"},"_id":"@repeaterjs/repeater@3.0.6","dist":{"shasum":"be23df0143ceec3c69f8b6c2517971a5578fdaa2","size":20190,"noattachment":false,"key":"/@repeaterjs/repeater/-/@repeaterjs/repeater-3.0.6.tgz","tarball":"http://registry.cnpm.dingdandao.com/@repeaterjs/repeater/download/@repeaterjs/repeater-3.0.6.tgz"},"_npmUser":{"name":"brainkim","email":"briankimpossible@gmail.com"},"directories":{},"maintainers":[{"name":"brainkim","email":"briankimpossible@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/repeater_3.0.6_1715198331673_0.9482979268675351"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-05-08T19:58:51.835Z","publish_time":1715198331835,"_source_registry_name":"default","_cnpm_publish_time":1715198331835},"3.0.5":{"name":"@repeaterjs/repeater","version":"3.0.5","description":"The missing constructor function for creating safe async iterators","repository":{"type":"git","url":"https://github.com/repeaterjs/repeater","directory":"packages/repeater"},"license":"MIT","type":"module","main":"cjs/repeater.js","module":"repeater.js","types":"repeater.d.ts","exports":{".":{"require":{"types":"./cjs/repeater.d.ts","default":"./cjs/repeater.js"},"types":"./repeater.d.ts","default":"./repeater.js"}},"scripts":{"prebuild":"yarn run clean","build":"rollup -c ./rollup.config.js","clean":"shx rm -rf cjs dist repeater.js *.d.ts *.js.map","lint":"eslint --ext ts src","prepublishOnly":"yarn run test && yarn run build","test":"jest --config ./jest.config.cjs --rootDir ./ --color"},"devDependencies":{"@types/jest":"^26.0.7","@typescript-eslint/eslint-plugin":"^3.7.1","@typescript-eslint/parser":"^3.7.1","eslint":"^7.5.0","eslint-config-prettier":"^6.4.0","eslint-config-recommended-plus-types":"^1.0.0","eslint-plugin-jest":"^23.20.0","eslint-plugin-prettier":"^3.1.4","jest":"^26.2.1","magic-string":"^0.25.7","prettier":"^2.0.5","rollup":"^2.23.0","rollup-plugin-typescript2":"^0.27.1","shx":"^0.3.2","ts-jest":"^26.1.4","ts-transform-import-path-rewrite":"^0.2.1","typescript":"^3.9.7"},"publishConfig":{"access":"public"},"_id":"@repeaterjs/repeater@3.0.5","dist":{"shasum":"b77571685410217a548a9c753aa3cdfc215bfc78","size":20159,"noattachment":false,"key":"/@repeaterjs/repeater/-/@repeaterjs/repeater-3.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/@repeaterjs/repeater/download/@repeaterjs/repeater-3.0.5.tgz"},"_npmUser":{"name":"brainkim","email":"briankimpossible@gmail.com"},"directories":{},"maintainers":[{"name":"brainkim","email":"briankimpossible@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/repeater_3.0.5_1699387601641_0.7923988118414977"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-11-07T20:06:41.800Z","publish_time":1699387601800,"_source_registry_name":"default","_cnpm_publish_time":1699387601800},"3.0.4":{"name":"@repeaterjs/repeater","version":"3.0.4","description":"The missing constructor function for creating safe async iterators","repository":{"type":"git","url":"https://github.com/repeaterjs/repeater","directory":"packages/repeater"},"license":"MIT","type":"module","main":"cjs/repeater.js","module":"repeater.js","types":"repeater.d.ts","scripts":{"prebuild":"yarn run clean","build":"rollup -c ./rollup.config.js","clean":"shx rm -rf cjs dist repeater.js *.d.ts *.js.map","lint":"eslint --ext ts src","prepublishOnly":"yarn run test && yarn run build","test":"jest --config ./jest.config.cjs --rootDir ./ --color"},"devDependencies":{"@types/jest":"^26.0.7","@typescript-eslint/eslint-plugin":"^3.7.1","@typescript-eslint/parser":"^3.7.1","eslint":"^7.5.0","eslint-config-prettier":"^6.4.0","eslint-config-recommended-plus-types":"^1.0.0","eslint-plugin-jest":"^23.20.0","eslint-plugin-prettier":"^3.1.4","jest":"^26.2.1","magic-string":"^0.25.7","prettier":"^2.0.5","rollup":"^2.23.0","rollup-plugin-typescript2":"^0.27.1","shx":"^0.3.2","ts-jest":"^26.1.4","ts-transform-import-path-rewrite":"^0.2.1","typescript":"^3.9.7"},"publishConfig":{"access":"public"},"_id":"@repeaterjs/repeater@3.0.4","dist":{"shasum":"a04d63f4d1bf5540a41b01a921c9a7fddc3bd1ca","size":20052,"noattachment":false,"key":"/@repeaterjs/repeater/-/@repeaterjs/repeater-3.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/@repeaterjs/repeater/download/@repeaterjs/repeater-3.0.4.tgz"},"maintainers":[{"name":"brainkim","email":"briankimpossible@gmail.com"}],"_npmUser":{"name":"brainkim","email":"briankimpossible@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/repeater_3.0.4_1599080751549_0.8591168714966464"},"_hasShrinkwrap":false,"publish_time":1599080751651,"_cnpm_publish_time":1599080751651},"3.0.3":{"name":"@repeaterjs/repeater","version":"3.0.3","description":"The missing constructor function for creating safe async iterators","type":"module","repository":{"type":"git","url":"https://github.com/repeaterjs/repeater","directory":"packages/repeater"},"license":"MIT","main":"cjs/repeater.js","module":"repeater.js","types":"repeater.d.ts","scripts":{"prebuild":"yarn run clean","build":"rollup -c ./rollup.config.js","clean":"shx rm -rf cjs dist repeater.js *.d.ts *.js.map","lint":"eslint --ext ts src","prepublishOnly":"yarn run test && yarn run build","test":"jest --config ./jest.config.cjs --rootDir ./ --color"},"dependencies":{"magic-string":"^0.25.7","ts-transform-import-path-rewrite":"^0.2.1"},"devDependencies":{"@types/jest":"^26.0.7","@typescript-eslint/eslint-plugin":"^3.7.1","@typescript-eslint/parser":"^3.7.1","eslint":"^7.5.0","eslint-config-prettier":"^6.4.0","eslint-config-recommended-plus-types":"^1.0.0","eslint-plugin-jest":"^23.20.0","eslint-plugin-prettier":"^3.1.4","jest":"^26.2.1","prettier":"^2.0.5","rollup":"^2.23.0","rollup-plugin-typescript2":"^0.27.1","shx":"^0.3.2","ts-jest":"^26.1.4","typescript":"^3.9.7"},"publishConfig":{"access":"public"},"_id":"@repeaterjs/repeater@3.0.3","dist":{"shasum":"873dc5ddb8892c964f9d548faa4bb8137811f6f1","size":19337,"noattachment":false,"key":"/@repeaterjs/repeater/-/@repeaterjs/repeater-3.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/@repeaterjs/repeater/download/@repeaterjs/repeater-3.0.3.tgz"},"maintainers":[{"name":"brainkim","email":"briankimpossible@gmail.com"}],"_npmUser":{"name":"brainkim","email":"briankimpossible@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/repeater_3.0.3_1596480450304_0.6369663800754501"},"_hasShrinkwrap":false,"publish_time":1596480450841,"_cnpm_publish_time":1596480450841},"3.0.2":{"name":"@repeaterjs/repeater","version":"3.0.2","description":"The missing constructor function for creating safe async iterators","type":"module","repository":{"type":"git","url":"https://github.com/repeaterjs/repeater","directory":"packages/repeater"},"license":"MIT","main":"cjs/repeater.js","module":"repeater.js","types":"repeater.d.ts","scripts":{"prebuild":"yarn run clean","build":"rollup -c ./rollup.config.js","clean":"shx rm -rf cjs dist repeater.js *.d.ts *.js.map","lint":"eslint --ext ts src","prepublishOnly":"yarn run test && yarn run build","test":"jest --config ./jest.config.cjs --rootDir ./ --color"},"dependencies":{"magic-string":"^0.25.7","ts-transform-import-path-rewrite":"^0.2.1"},"devDependencies":{"@types/jest":"^26.0.7","@typescript-eslint/eslint-plugin":"^3.7.1","@typescript-eslint/parser":"^3.7.1","eslint":"^7.5.0","eslint-config-prettier":"^6.4.0","eslint-config-recommended-plus-types":"^1.0.0","eslint-plugin-jest":"^23.20.0","eslint-plugin-prettier":"^3.1.4","jest":"^26.2.1","prettier":"^2.0.5","rollup":"^2.23.0","rollup-plugin-typescript2":"^0.27.1","shx":"^0.3.2","ts-jest":"^26.1.4","typescript":"^3.9.7"},"publishConfig":{"access":"public"},"_id":"@repeaterjs/repeater@3.0.2","dist":{"shasum":"375c4493dbf91832b6d7178db9e08fd54cea90fa","size":11149,"noattachment":false,"key":"/@repeaterjs/repeater/-/@repeaterjs/repeater-3.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/@repeaterjs/repeater/download/@repeaterjs/repeater-3.0.2.tgz"},"maintainers":[{"name":"brainkim","email":"briankimpossible@gmail.com"}],"_npmUser":{"name":"brainkim","email":"briankimpossible@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/repeater_3.0.2_1596480152698_0.5909643734242076"},"_hasShrinkwrap":false,"publish_time":1596480152804,"_cnpm_publish_time":1596480152804},"3.0.1":{"name":"@repeaterjs/repeater","version":"3.0.1","description":"The missing constructor function for creating safe async iterators","repository":{"type":"git","url":"https://github.com/repeaterjs/repeater","directory":"packages/repeater"},"license":"MIT","main":"lib/repeater.cjs.js","module":"lib/repeater.esm.js","types":"lib/repeater.d.ts","scripts":{"prebuild":"yarn run clean","build":"rollup -c ./rollup.config.js","clean":"shx rm -rf ./lib","lint":"eslint --ext ts src","prepublishOnly":"yarn run test && yarn run build","test":"jest --config ./jest.config.js --rootDir --color"},"devDependencies":{"@types/jest":"^24.0.18","@typescript-eslint/eslint-plugin":"^2.3.3","@typescript-eslint/parser":"^2.3.3","eslint":"^6.5.1","eslint-config-prettier":"^6.4.0","eslint-config-recommended-plus-types":"^1.0.0","eslint-plugin-jest":"^22.19.0","eslint-plugin-prettier":"^3.1.1","jest":"^24.9.0","prettier":"^1.18.2","rollup":"^1.23.1","rollup-plugin-typescript2":"^0.24.3","shx":"^0.3.2","ts-jest":"^24.1.0","typescript":"^3.6.4","weak":"^1.0.1"},"publishConfig":{"access":"public"},"_id":"@repeaterjs/repeater@3.0.1","dist":{"shasum":"506641792ae5fdc5b8c3981ceb210bce407cd104","size":17280,"noattachment":false,"key":"/@repeaterjs/repeater/-/@repeaterjs/repeater-3.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@repeaterjs/repeater/download/@repeaterjs/repeater-3.0.1.tgz"},"maintainers":[{"name":"brainkim","email":"briankimpossible@gmail.com"}],"_npmUser":{"name":"brainkim","email":"briankimpossible@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/repeater_3.0.1_1573396569553_0.8782510979527076"},"_hasShrinkwrap":false,"publish_time":1573396569699,"_cnpm_publish_time":1573396569699},"3.0.0":{"name":"@repeaterjs/repeater","version":"3.0.0","description":"The missing constructor function for creating safe async iterators","repository":{"type":"git","url":"https://github.com/repeaterjs/repeater","directory":"packages/repeater"},"license":"MIT","main":"lib/repeater.cjs.js","module":"lib/repeater.esm.js","types":"lib/repeater.d.ts","scripts":{"prebuild":"yarn run clean","build":"rollup -c ./rollup.config.js","clean":"shx rm -rf ./lib","lint":"eslint --ext ts src","prepublishOnly":"yarn run test && yarn run build","test":"jest --config ./jest.config.js --rootDir --color"},"devDependencies":{"@types/jest":"^24.0.18","@typescript-eslint/eslint-plugin":"^2.3.3","@typescript-eslint/parser":"^2.3.3","eslint":"^6.5.1","eslint-config-prettier":"^6.4.0","eslint-config-recommended-plus-types":"^1.0.0","eslint-plugin-jest":"^22.19.0","eslint-plugin-prettier":"^3.1.1","jest":"^24.9.0","prettier":"^1.18.2","rollup":"^1.23.1","rollup-plugin-typescript2":"^0.24.3","shx":"^0.3.2","ts-jest":"^24.1.0","typescript":"^3.6.4","weak":"^1.0.1"},"publishConfig":{"access":"public"},"_id":"@repeaterjs/repeater@3.0.0","dist":{"shasum":"79a4bf454d7ffc518dccc9181c4325a9d51179ee","size":7298,"noattachment":false,"key":"/@repeaterjs/repeater/-/@repeaterjs/repeater-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@repeaterjs/repeater/download/@repeaterjs/repeater-3.0.0.tgz"},"maintainers":[{"name":"brainkim","email":"briankimpossible@gmail.com"}],"_npmUser":{"name":"brainkim","email":"briankimpossible@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/repeater_3.0.0_1573389490413_0.624541135916916"},"_hasShrinkwrap":false,"publish_time":1573389490555,"_cnpm_publish_time":1573389490555},"3.0.0-beta.1":{"name":"@repeaterjs/repeater","version":"3.0.0-beta.1","description":"The missing constructor function for creating safe async iterators","repository":{"type":"git","url":"https://github.com/repeaterjs/repeater","directory":"packages/repeater"},"license":"MIT","main":"lib/repeater.cjs.js","module":"lib/repeater.esm.js","types":"lib/repeater.d.ts","scripts":{"prebuild":"yarn run clean","build":"rollup -c ./rollup.config.js","clean":"shx rm -rf ./lib","lint":"eslint --ext ts src","prepublishOnly":"yarn run test && yarn run build","test":"jest --config ./jest.config.js --rootDir --color"},"devDependencies":{"@types/jest":"^24.0.18","@typescript-eslint/eslint-plugin":"^2.3.3","@typescript-eslint/parser":"^2.3.3","eslint":"^6.5.1","eslint-config-prettier":"^6.4.0","eslint-config-recommended-plus-types":"^1.0.0","eslint-plugin-jest":"^22.19.0","eslint-plugin-prettier":"^3.1.1","jest":"^24.9.0","prettier":"^1.18.2","rollup":"^1.23.1","rollup-plugin-typescript2":"^0.24.3","shx":"^0.3.2","ts-jest":"^24.1.0","typescript":"^3.6.4","weak":"^1.0.1"},"publishConfig":{"access":"public"},"readmeFilename":"README.md","_id":"@repeaterjs/repeater@3.0.0-beta.1","dist":{"shasum":"ccb3fbde8a7d0393094db861481d1c4bc7f6cbd1","size":6777,"noattachment":false,"key":"/@repeaterjs/repeater/-/@repeaterjs/repeater-3.0.0-beta.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@repeaterjs/repeater/download/@repeaterjs/repeater-3.0.0-beta.1.tgz"},"maintainers":[{"name":"brainkim","email":"briankimpossible@gmail.com"}],"_npmUser":{"name":"brainkim","email":"briankimpossible@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/repeater_3.0.0-beta.1_1572231875112_0.9366097122430375"},"_hasShrinkwrap":false,"publish_time":1572231875235,"_cnpm_publish_time":1572231875235},"2.0.0":{"name":"@repeaterjs/repeater","version":"2.0.0","description":"The missing constructor function for creating safe async iterators","repository":{"type":"git","url":"https://github.com/repeaterjs/repeater","directory":"packages/repeater"},"license":"MIT","main":"lib/repeater.cjs.js","module":"lib/repeater.esm.js","types":"lib/repeater.d.ts","scripts":{"prebuild":"yarn run clean","build":"rollup -c ../../rollup.config.js","clean":"shx rm -rf ./lib","lint":"eslint --ext ts src","prepublishOnly":"yarn run test && yarn run build","test":"jest --config ../../jest.config.js --rootDir --color"},"devDependencies":{"@types/jest":"^24.0.18","@typescript-eslint/eslint-plugin":"^2.0.0","@typescript-eslint/parser":"^2.0.0","eslint":"^6.2.1","eslint-config-prettier":"^6.1.0","eslint-plugin-jest":"^22.15.2","eslint-plugin-prettier":"^3.1.0","jest":"^24.9.0","prettier":"^1.18.2","rollup":"^1.20.0","rollup-plugin-typescript2":"^0.22.1","shx":"^0.3.2","ts-jest":"^24.0.0","typescript":"^3.5.3","weak":"^1.0.1"},"publishConfig":{"access":"public"},"_id":"@repeaterjs/repeater@2.0.0","dist":{"shasum":"06e906c7bbd24f4707cbed74704cbace38ec2009","size":15137,"noattachment":false,"key":"/@repeaterjs/repeater/-/@repeaterjs/repeater-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@repeaterjs/repeater/download/@repeaterjs/repeater-2.0.0.tgz"},"maintainers":[{"name":"brainkim","email":"briankimpossible@gmail.com"}],"_npmUser":{"name":"brainkim","email":"briankimpossible@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/repeater_2.0.0_1566680472388_0.5209562579739597"},"_hasShrinkwrap":false,"publish_time":1566680472646,"_cnpm_publish_time":1566680472646},"1.0.0":{"name":"@repeaterjs/repeater","version":"1.0.0","description":"The missing constructor function for creating safe async iterators","license":"MIT","homepage":"https://channel.js.org/","repository":{"type":"git","url":"https://github.com/repeaterjs/repeater","directory":"packages/channel"},"main":"lib/index.cjs.js","module":"lib/index.esm.js","types":"lib/index.d.ts","scripts":{"prebuild":"yarn run clean","build":"rollup -c ../../rollup.config.js","clean":"shx rm -rf ./lib","test":"jest --config ../../jest.config.js --rootDir --color","lint":"eslint --ext ts src","prepublishOnly":"yarn run test && yarn run build"},"publishConfig":{"access":"public"},"_id":"@repeaterjs/repeater@1.0.0","dist":{"shasum":"adf1496df7fee33dff31fb54074ef0174d2b4b38","size":14741,"noattachment":false,"key":"/@repeaterjs/repeater/-/@repeaterjs/repeater-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@repeaterjs/repeater/download/@repeaterjs/repeater-1.0.0.tgz"},"maintainers":[{"name":"brainkim","email":"briankimpossible@gmail.com"}],"_npmUser":{"name":"brainkim","email":"briankimpossible@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/repeater_1.0.0_1566442907743_0.07003991708593804"},"_hasShrinkwrap":false,"publish_time":1566442907957,"_cnpm_publish_time":1566442907957}},"readme":"# Repeater.js\nThe missing constructor for creating safe async iterators.\n\nFor more information, visit [repeater.js.org](https://repeater.js.org).\n\n## Installation\n\nRepeater.js is available on [npm](https://www.npmjs.com/package/@repeaterjs/repeater) in the CommonJS and ESModule formats.\n\n`$ npm install @repeaterjs/repeater`\n\n`$ yarn add @repeaterjs/repeater`\n\n## Requirements\n\nThe core `@repeaterjs/repeater` module has no dependencies, but requires the following globals in order to work:\n- `Promise`\n- `WeakMap`\n- `Symbol`\n  - `Symbol.iterator`\n  - `Symbol.asyncIterator`\n\nIn addition, repeaters are most useful when used via `async/await` and `for await…of` syntax. You can transpile your code with babel or typescript to support enviroments which lack these features.\n\n## Examples\n\n<h4 id=\"timestamps\">Logging timestamps with setInterval</h4>\n\n```js\nimport { Repeater } from \"@repeaterjs/repeater\";\n\nconst timestamps = new Repeater(async (push, stop) => {\n  push(Date.now());\n  const interval = setInterval(() => push(Date.now()), 1000);\n  await stop;\n  clearInterval(interval);\n});\n\n(async function() {\n  let i = 0;\n  for await (const timestamp of timestamps) {\n    console.log(timestamp);\n    i++;\n    if (i >= 10) {\n      console.log(\"ALL DONE!\");\n      break; // triggers clearInterval above\n    }\n  }\n})();\n```\n\n<h4 id=\"websocket\">Creating a repeater from a websocket</h4>\n\n```js\nimport { Repeater } from \"@repeaterjs/repeater\";\n\nconst socket = new WebSocket(\"ws://echo.websocket.org\");\nconst messages = new Repeater(async (push, stop) => {\n  socket.onmessage = (ev) => push(ev.data);\n  socket.onerror = () => stop(new Error(\"WebSocket error\"));\n  socket.onclose = () => stop();\n  await stop;\n  socket.close();\n});\n\n(async function() {\n  for await (const message of messages) {\n    console.log(message);\n    if (message === \"close\") {\n      console.log(\"Closing!\");\n      break; // closes the socket\n    }\n  }\n})();\n\nsocket.onopen = () => {\n  socket.send(\"hello\"); // \"hello\"\n  socket.send(\"world\"); // \"world\"\n  socket.send(\"close\"); // \"close\", \"Closing!\"\n};\n```\n\n<h4 id=\"konami-code\">Listening for the <a href=\"https://en.wikipedia.org/wiki/Konami_Code\">Konami Code</a> and canceling if <kbd>Escape</kbd> is pressed</h4>\n\n```js\nimport { Repeater } from \"@repeaterjs/repeater\";\n\nconst keys = new Repeater(async (push, stop) => {\n  const listener = (ev) => {\n    if (ev.key === \"Escape\") {\n      stop();\n    } else {\n      push(ev.key);\n    }\n  };\n  window.addEventListener(\"keyup\", listener);\n  await stop;\n  window.removeEventListener(\"keyup\", listener);\n});\n\nconst konami = [\"ArrowUp\", \"ArrowUp\", \"ArrowDown\", \"ArrowDown\", \"ArrowLeft\", \"ArrowRight\", \"ArrowLeft\", \"ArrowRight\", \"b\", \"a\"];\n\n(async function() {\n  let i = 0;\n  for await (const key of keys) {\n    if (key === konami[i]) {\n      i++;\n    } else {\n      i = 0;\n    }\n    if (i >= konami.length) {\n      console.log(\"KONAMI!!!\");\n      break; // removes the keyup listener\n    }\n  }\n})();\n```\n\n<h4 id=\"observables\">Converting an observable to an async iterator</h4>\n\n```js\nimport { Subject } from \"rxjs\";\nimport { Repeater } from \"@repeaterjs/repeater\";\n\nconst observable = new Subject();\nconst repeater = new Repeater(async (push, stop) => {\n  const subscription = observable.subscribe({\n    next: (value) => push(value),\n    error: (err) => stop(err),\n    complete: () => stop(),\n  });\n  await stop;\n  subscription.unsubscribe();\n});\n\n(async function() {\n  try {\n    for await (const value of repeater) {\n      console.log(\"Value: \", value);\n    }\n  } catch (err) {\n    console.log(\"Error caught: \", err);\n  }\n})();\nobservable.next(1);\n// Value: 1\nobservable.next(2);\n// Value: 2\nobservable.error(new Error(\"Hello from observable\"));\n// Error caught: Error: Hello from observable\n```\n","_attachments":{},"license":"MIT"}