{"name":"any-signal","version":"3.0.0","description":"Combines an array of AbortSignals into a single signal that is aborted when any signal is","main":"index.js","types":"index.d.ts","scripts":{"test":"npm run lint && nyc --reporter=lcov --reporter=text ava --verbose","lint":"standard"},"keywords":[],"author":{"name":"Jacob Heun"},"license":"MIT","devDependencies":{"ava":"^3.11.1","nyc":"^15.1.0","p-defer":"^3.0.0","standard":"^16.0.3"},"repository":{"type":"git","url":"git+https://github.com/jacobheun/any-signal.git"},"bugs":{"url":"https://github.com/jacobheun/any-signal/issues"},"homepage":"https://github.com/jacobheun/any-signal#readme","gitHead":"1ffe15b91e43f70e271ee3e1e0842cb4c595b8b2","_id":"any-signal@3.0.0","_nodeVersion":"16.10.0","_npmVersion":"7.24.0","dist":{"integrity":"sha512-l1H1GEkGGIXVGfCtvq8N68YI7gHajmfzRdKhmb8sGyAQpLCblirLa8eB09j4uKaiwe7vodAChocUf7AT3mYq5g==","shasum":"4f6ee491e5cdda9e9a544f50fdf1d14be40535b6","tarball":"http://registry-npm.ywwl.com/any-signal/download/any-signal-3.0.0.tgz","fileCount":5,"unpackedSize":4798,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh3rvhCRA9TVsSAnZWagAAc+YP/jtTytE7UpoffTbBMFm+\nUm9Zl+Xl2PoDPoVAN+9vgVOcUj5DyErU6e4/O8WiG5oVgthOzsEXa94m1oly\n4xg1/Ck1FOAyARvjQZgTbcMvE8wAulOx6cmB47qyknrJ0F9fi3CtSt6ITxev\nRd1npWm+Jx108WJ30bUU7pvtq+uINjrhdP1c96496THFPSB64Aj91Oi0O+yg\nrMvTnq7H7dUnADQkiHe785g4h75q4pW0z9IZoUchtMGvwcVBzHAkxnWNc5RC\nMmfbhtz2+qivt0WLBjyQKtlTBLgEt9Sr/pSCoitHoy1TBPEaPQSFRbntjeT5\nS1McF5qbkgIcLxX6udECuxnSQoRvug+kDDCGQJ8XfJeFmiLYOQyFlM+b9vEu\nQHrHMpkPT1wwx8JuAlBRzJZdlaRHFJLZft8GX3diBrelDHKn/IJldcN8Y66G\ne3fus4pCrTqc899UokAM0WiYOLvk7wOw2AOzjbUsiH2ALG9KkfuEZDn8vDk4\nNpAUZTefql/h7OsuYV2iBi3+aTMkZCzZbpjo0Cyin/C+4hbjTT8eUgvsofOX\nx4/A0T+jQRfYqyAve1Z3ThsDoHyd1n3wB29+9LspYHMhtGtFvUJJX6ZjzT1h\nkVR1CsBb/g4azmOweUJMW+l9PsDIjL8QKC9n4McXN3DHtZsQ8kMDaAhTd1K/\nx+RS\r\n=Xwrr\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDlotiSFQOv3qmHUNMpLpHNlRXtvAVgA1yGvcoIzbw+nAIgZ13VB9ftsbIN8QOWZQyMoPmPNcVm2k8EQZ1WnBZFrZs="}],"size":2245,"noattachment":false,"key":"/any-signal/-/any-signal-3.0.0.tgz"},"_npmUser":{"name":"jacobheun","email":"jacobheun@gmail.com"},"directories":{},"maintainers":[{"name":"jacobheun","email":"jacobheun@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/any-signal_3.0.0_1641987041744_0.389956947198963"},"_hasShrinkwrap":false,"readme":"# any-signal <!-- omit in toc -->\n\n[![codecov](https://img.shields.io/codecov/c/github/jacobheun/any-signal.svg?style=flat-square)](https://codecov.io/gh/jacobheun/any-signal)\n[![CI](https://img.shields.io/github/actions/workflow/status/jacobheun/any-signal/js-test-and-release.yml?branch=master\\&style=flat-square)](https://github.com/jacobheun/any-signal/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)\n\n> Combines an array of AbortSignals into a single signal that is aborted when any signal is\n\n## Table of contents <!-- omit in toc -->\n\n- [Install](#install)\n  - [Browser `<script>` tag](#browser-script-tag)\n- [Usage](#usage)\n- [API](#api)\n  - [`anySignal(signals)`](#anysignalsignals)\n    - [Parameters](#parameters)\n    - [Returns](#returns)\n  - [`ClearableSignal.clear()`](#clearablesignalclear)\n- [Acknowledgements](#acknowledgements)\n- [API Docs](#api-docs)\n- [License](#license)\n- [Contribution](#contribution)\n\n## Install\n\n```console\n$ npm i any-signal\n```\n\n### Browser `<script>` tag\n\nLoading this module through a script tag will make it's exports available as `AnySignal` in the global namespace.\n\n```html\n<script src=\"https://unpkg.com/any-signal/dist/index.min.js\"></script>\n```\n\n## Usage\n\n```js\nimport { anySignal } from 'any-signal'\n\nconst userController = new AbortController()\nconst timeoutController = new AbortController()\n\nconst combinedSignal = anySignal([userController.signal, timeoutController.signal])\ncombinedSignal.addEventListener('abort', () => console.log('Abort!'))\n\n// Abort after 1 second\nconst timeoutId = setTimeout(() => timeoutController.abort(), 1000)\n\n// The user or the timeout can now abort the action\nawait performSomeAction({ signal: combinedSignal })\nclearTimeout(timeoutId)\n\n// Clear will clean up internal event handlers\ncombinedSignal.clear()\n```\n\n## API\n\n### `anySignal(signals)`\n\n#### Parameters\n\n| Name    | Type                                                                                 | Description                                                         |\n| ------- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------- |\n| signals | Array<[`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)> | The Signals that will be observed and mapped to the returned Signal |\n\n#### Returns\n\n| Type                                                                              | Description                                                                                                                                   |\n| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |\n| [`ClearableSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) | A Signal that will be aborted as soon as any one of its parent signals are aborted. Extends AbortSignal with the `clear` function for cleanup |\n\nThe returned [`ClearableSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) will only be aborted once, and as soon as one of its parent signals is aborted.\n\n### `ClearableSignal.clear()`\n\nRemoves all internal event handlers. This **must** be called after abort has been called, or the signals have successfully executed, otherwise there is a risk of leaking event handlers.\n\n## Acknowledgements\n\nThe anySignal function is taken from a [comment by jakearchibald](https://github.com/whatwg/fetch/issues/905#issuecomment-491970649)\n\n## API Docs\n\n- <https://jacobheun.github.io/any-signal>\n\n## License\n\nLicensed under either of\n\n- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)\n- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","publish_time":1641987041914,"_cnpm_publish_time":1641987041914,"dist-tags":{"latest":"4.2.0"}}