{"id":21703569,"url":"https://github.com/codemonument/deno_simple_timer_stream","last_synced_at":"2026-05-15T23:40:33.692Z","repository":{"id":62752812,"uuid":"562240107","full_name":"codemonument/deno_simple_timer_stream","owner":"codemonument","description":"A simle timer as a webstream by @codemonument","archived":false,"fork":false,"pushed_at":"2023-07-03T07:28:54.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-25T15:41:25.579Z","etag":null,"topics":["deno","deno-module"],"latest_commit_sha":null,"homepage":"https://deno.land/x/simple_timer_stream","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codemonument.png","metadata":{"files":{"readme":"Readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-05T18:18:56.000Z","updated_at":"2022-11-05T20:05:38.000Z","dependencies_parsed_at":"2024-11-25T21:43:42.279Z","dependency_job_id":null,"html_url":"https://github.com/codemonument/deno_simple_timer_stream","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":"codemonument/deno_module_template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonument%2Fdeno_simple_timer_stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonument%2Fdeno_simple_timer_stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonument%2Fdeno_simple_timer_stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonument%2Fdeno_simple_timer_stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemonument","download_url":"https://codeload.github.com/codemonument/deno_simple_timer_stream/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244656473,"owners_count":20488638,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deno","deno-module"],"created_at":"2024-11-25T21:33:36.688Z","updated_at":"2026-05-15T23:40:28.673Z","avatar_url":"https://github.com/codemonument.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Timer Stream\n\n## Heads Up: Moved!\n\nThis project was integrated into my [rx_webstreams library](https://github.com/codemonument/deno_rx_webstreams#timersource)!  \nSince this project is basically feature complete, you could still use this.  \nHowever, the rx_webstreams library has even more awesome stream utilities, so check it out!\n\nUseful Links:\n\n- timerSource() Tests: https://github.com/codemonument/deno_rx_webstreams/blob/main/lib/sources/timerSource.test.ts\n\nNote: The Explanation below does also work with timerSource() and is currently even better than in the rx_webstreams repository.\nSo, feel free to use this right now.  \nI plan on releasing a full featured documentation site for rx_webstreams.  \nWhen that happens, I'll update this readme with a link!\n\n# Original Readme\n\n## Description\n\nA simple function which starts a timer with setInterval and returns a ReadableStream Instance (Web Streams).\n\nVersion 1.0.0 is considered feature complete right now.\nIt will receive bugfixes, if I get notified of them or find the bugs myself.\nIf someone has a nice feature which would greatly benefit this package, [raise an issue](https://github.com/codemonument/deno_simple_timer_stream/issues) or even better,\n[submit a PR](https://github.com/codemonument/deno_simple_timer_stream/pulls) ! :)\n\n## Features\n\n- Create a finite timerstream with 5 events, 1 per second per default\n- Create a finite timerstream with x events, 1 per x ms (via options object)\n- Create an infinite timerstream by passing an abortSignal into the options object\n\n## Simple Usage\n\nSimply start a simpleTimerStream by calling its function: `simpleTimerStream()`.  \nPer default, it will emit 5 events, 1 per second.\n\nThese Events can be read simply via a `for await` loop:\n\n```ts\nfor await (const eventCount of simpleTimerStream()) {\n\tconsole.log(event);\n}\n```\n\n## Parametrized Usage\n\nTo change the `maxEventsCount` and `intervalInMilliseconds` values, simply pass an options object into `simpleTimerStream()`:\n\n```ts\nconst timer = simpleTimerStream({\n\tintervalInMilliseconds: 500,\n\tmaxEventCount: 5,\n});\n\nfor await (const event of timer) {\n\tconsole.log(event);\n}\n```\n\n## Usage with abort controller (infinite mode)\n\nTo use this `simpleTimerStream()` with an abort controller, simply pass an abortSignal into the options:\n\n```ts\nconst abortController = new AbortController();\n\nconst timer = simpleTimerStream({\n\tintervalInMilliseconds: 1000,\n\tabortSignal: abortController.signal,\n});\n\nfor await (const event of timer) {\n\tconsole.log(event);\n}\n```\n\nThis timer stream will go until you call abortController.abort().\nPlease note that you can't call `abortController.abort()` in the same function below the `for await` statement,\nsince this `for await` statement blocks execution of the function indefinitely.\n\nOne solution to this problem would be to define the condition, where the abort controller should abort,\nabove the `for await` structure. I'm using a setTimeout in this examle:\n\n```ts\nconst abortController = new AbortController();\n\nconst timeoutId = setTimeout(() =\u003e {\n\tabortController.abort();\n}, 4500);\n\nconst timer = simpleTimerStream({\n\tintervalInMilliseconds: 1000,\n\tabortSignal: abortController.signal,\n});\n\nfor await (const event of timer) {\n\tconsole.log(event);\n}\n\n// this is necessary to not have dangling async listeners in deno tests\nclearTimeout(timeoutId);\n```\n\n## Useful for\n\n- Testing custom WriteableStream Instances!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemonument%2Fdeno_simple_timer_stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemonument%2Fdeno_simple_timer_stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemonument%2Fdeno_simple_timer_stream/lists"}