{"id":24583695,"url":"https://github.com/toebeann/signals","last_synced_at":"2025-04-28T10:39:24.437Z","repository":{"id":57033923,"uuid":"526904507","full_name":"toebeann/signals","owner":"toebeann","description":"A collection of wrappers and utility functions for working with AbortSignals.","archived":false,"fork":false,"pushed_at":"2025-04-01T15:05:00.000Z","size":1371,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T05:52:17.163Z","etag":null,"topics":["abort","abortcontroller","abortsignal","aggregate-signal","aggregatesignal","any-signal","anysignal","is-abort-signal","is-signal","isabortsignal","issignal","javascript","nodejs","npm","signal","timeout","timeout-signal","timeoutsignal","typescript"],"latest_commit_sha":null,"homepage":"https://toebeann.github.io/signals","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/toebeann.png","metadata":{"funding":{"github":["toebeann"],"ko_fi":"toebean_","custom":["https://paypal.me/tobeyblaber"]},"files":{"readme":"README.md","changelog":null,"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-08-20T11:16:53.000Z","updated_at":"2024-09-26T22:56:39.000Z","dependencies_parsed_at":"2023-02-14T09:47:04.059Z","dependency_job_id":"434e3a9d-411e-42a4-b7d6-2ba92cbdc4fd","html_url":"https://github.com/toebeann/signals","commit_stats":{"total_commits":192,"total_committers":2,"mean_commits":96.0,"dds":0.203125,"last_synced_commit":"4a4a21e6365157a74693eb69b31a44e5b2006662"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toebeann%2Fsignals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toebeann%2Fsignals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toebeann%2Fsignals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toebeann%2Fsignals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toebeann","download_url":"https://codeload.github.com/toebeann/signals/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251296685,"owners_count":21566655,"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":["abort","abortcontroller","abortsignal","aggregate-signal","aggregatesignal","any-signal","anysignal","is-abort-signal","is-signal","isabortsignal","issignal","javascript","nodejs","npm","signal","timeout","timeout-signal","timeoutsignal","typescript"],"created_at":"2025-01-24T04:48:21.713Z","updated_at":"2025-04-28T10:39:24.419Z","avatar_url":"https://github.com/toebeann.png","language":"TypeScript","readme":"\u003ccenter\u003e\n\n# signals 🚥\n\nA collection of wrappers and utility functions for working with [AbortSignals](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).\n\n[![npm package version](https://img.shields.io/npm/v/@toebean/signals.svg?logo=npm\u0026label\u0026labelColor=222\u0026style=flat-square)](https://npmjs.org/package/@toebean/signals \"View signals on npm\") [![npm package downloads](https://img.shields.io/npm/dw/@toebean/signals.svg?logo=npm\u0026labelColor=222\u0026style=flat-square)](https://npmjs.org/package/@toebean/signals \"View signals on npm\") [![typedocs](https://img.shields.io/badge/docs-informational.svg?logo=typescript\u0026labelColor=222\u0026style=flat-square)](https://toebeann.github.io/signals \"Read the documentation on Github Pages\") [![license](https://img.shields.io/github/license/toebeann/signals.svg?logo=open-source-initiative\u0026logoColor=3DA639\u0026color=informational\u0026labelColor=222\u0026style=flat-square)](https://github.com/toebeann/signals/blob/main/LICENSE \"View the license on GitHub\")\n\n[![coverage](https://img.shields.io/codecov/c/github/toebeann/signals.svg?logo=codecov\u0026labelColor=222\u0026style=flat-square)](https://codecov.io/gh/toebeann/signals \"View code coverage on Codecov\") [![code quality](https://img.shields.io/codefactor/grade/github/toebeann/signals.svg?logo=codefactor\u0026labelColor=222\u0026style=flat-square)](https://www.codefactor.io/repository/github/toebeann/signals \"View code quality on CodeFactor\") [![minzip](https://img.shields.io/bundlephobia/minzip/@toebean/signals.svg?labelColor=222\u0026style=flat-square)](https://bundlephobia.com/package/@toebean/signals \"View signals on Bundlephobia\") [![tree-shaking](https://flat.badgen.net/bundlephobia/tree-shaking/@toebean/signals?labelColor=222)](https://bundlephobia.com/package/@toebean/signals \"View signals on Bundlephobia\")\n\n[![npm test](https://img.shields.io/github/actions/workflow/status/toebeann/signals/npm-test.yml?branch=main\u0026logo=github\u0026logoColor=aaa\u0026label=npm%20test\u0026labelColor=222\u0026style=flat-square)](https://github.com/toebeann/signals/actions/workflows/npm-test.yml \"View npm test on GitHub Actions\") [![publish code coverage](https://img.shields.io/github/actions/workflow/status/toebeann/signals/publish-code-coverage.yml?branch=main\u0026logo=github\u0026logoColor=aaa\u0026label=publish%20code%20coverage\u0026labelColor=222\u0026style=flat-square)](https://github.com/toebeann/signals/actions/workflows/publish-code-coverage.yml \"View publish code coverage on GitHub Actions\") [![publish package](https://img.shields.io/github/actions/workflow/status/toebeann/signals/publish-package.yml?branch=main\u0026logo=github\u0026logoColor=aaa\u0026label=publish%20package\u0026labelColor=222\u0026style=flat-square)](https://github.com/toebeann/signals/actions/workflows/publish-package.yml \"View publish package on GitHub Actions\") [![publish docs](https://img.shields.io/github/actions/workflow/status/toebeann/signals/publish-docs.yml?branch=main\u0026logo=github\u0026logoColor=aaa\u0026label=publish%20docs\u0026labelColor=222\u0026style=flat-square)](https://github.com/toebeann/signals/actions/workflows/publish-docs.yml \"View publish docs on GitHub Actions\")\n\n[![github](https://img.shields.io/badge/source-informational.svg?logo=github\u0026labelColor=222\u0026style=flat-square)](https://github.com/toebeann/signals \"View signals on GitHub\") [![twitter](https://img.shields.io/badge/follow-blue.svg?logo=twitter\u0026label\u0026labelColor=222\u0026style=flat-square)](https://twitter.com/toebean__ \"Follow @toebean__ on Twitter\") [![GitHub Sponsors donation button](https://img.shields.io/badge/sponsor-e5b.svg?logo=github%20sponsors\u0026labelColor=222\u0026style=flat-square)](https://github.com/sponsors/toebeann \"Sponsor signals on GitHub\") [![PayPal donation button](https://img.shields.io/badge/donate-e5b.svg?logo=paypal\u0026labelColor=222\u0026style=flat-square)](https://paypal.me/tobeyblaber \"Donate to signals with PayPal\")\n\n\u003c/center\u003e\n\n## Table of contents\n\n- [signals 🚥](#signals-)\n  - [Table of contents](#table-of-contents)\n  - [Install](#install)\n    - [npm](#npm)\n  - [Usage](#usage)\n    - [AggregateSignal](#aggregatesignal)\n    - [TimeoutSignal](#timeoutsignal)\n    - [isAbortSignal](#isabortsignal)\n  - [API reference](#api-reference)\n    - [Quick links](#quick-links)\n  - [License](#license)\n\n## Install\n\n### [npm](https://www.npmjs.com/package/@toebean/signals \"npm is a package manager for JavaScript\")\n\n```text\nnpm i @toebean/signals\n```\n\n## Usage\n\n### AggregateSignal\n\nCombines several [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) instances into a signal which will be aborted as soon as any of the given signals are.\n\n```js\nimport { AggregateSignal } from \"@toebean/signals\";\n\nconst ac = new AbortController();\nconst aggregateSignal = new AggregateSignal(ac.signal, someOtherSignal);\n\n// passing an aggregate signal into an awaitable, abortable call:\nawait doSomeAbortableAction({ signal: aggregateSignal.signal });\n\n// determining which of the original signals was aborted first:\nswitch (aggregateSignal.abortedSignal) {\n  case ac.signal:\n    // do stuff\n    break;\n  // etc...\n}\n```\n\n### TimeoutSignal\n\nCreates an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) which will timeout after a given number of milliseconds, using [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout) under the hood.\n\n```js\nimport { AggregateSignal } from \"@toebean/signals\";\n\nconst timeoutSignal = new TimeoutSignal(200); // creates an AbortSignal which will abort in 200ms\n\n// passing a timeout signal into an awaitable, abortable call:\nawait doSomeAbortableAction({ signal: timeoutSignal.signal });\n\n// If for whatever reason you need to clear the underlying timeout of the TimeoutSignal, you can:\nclearTimeout(timeoutSignal.timeout);\n```\n\n### isAbortSignal\n\nA TypeScript type guard for checking whether a given object is an `AbortSignal`.\n\n```ts\nimport { isAbortSignal } from \"@toebean/signals\";\n\nif (isAbortSignal(someObject)) {\n  // within this block, someObject is typed as an AbortSignal\n  console.log(someObejct.aborted);\n}\n```\n\n## API reference\n\nThe full API reference for signals is [available on GitHub Pages](https://toebeann.github.io/signals).\n\n### Quick links\n\n- [AggregateSignal](https://toebeann.github.io/signals/stable/classes/AggregateSignal.html)\n- [TimeoutSignal](https://toebeann.github.io/signals/stable/classes/TimeoutSignal.html)\n- [isAbortSignal](https://toebeann.github.io/signals/stable/functions/isAbortSignal.html)\n\n## License\n\nsignals is licensed under [MIT](https://github.com/toebeann/signals/blob/main/LICENSE) © 2022 Tobey Blaber.\n","funding_links":["https://github.com/sponsors/toebeann","https://ko-fi.com/toebean_","https://paypal.me/tobeyblaber"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoebeann%2Fsignals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoebeann%2Fsignals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoebeann%2Fsignals/lists"}