{"name":"any-signal","version":"1.2.0","description":"Combines an array of AbortSignals into a single signal that is aborted when any signal is","main":"index.js","scripts":{"test":"npm run lint && nyc --reporter=lcov --reporter=text ava --verbose","lint":"standard"},"keywords":[],"author":{"name":"Jacob Heun"},"license":"MIT","browser":{"./abort-controller.js":"./abort-controller.browser.js"},"dependencies":{"abort-controller":"^3.0.0"},"devDependencies":{"ava":"^3.11.1","nyc":"^15.1.0","p-defer":"^3.0.0","standard":"^14.3.1"},"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":"faf310edeb77affe704bc66b0e72f02263469525","_id":"any-signal@1.2.0","_nodeVersion":"14.5.0","_npmVersion":"6.14.5","dist":{"integrity":"sha512-Cl08k4xItix3jvu4cxO/dt2rQ6iUAjO66pTyRMub+WL1VXeAyZydCpD8GqWTPKfdL28U0R0UucmQVsUsBnvCmQ==","shasum":"d755f690896f3e75c4a07480f429a1ee7f8db3b4","tarball":"http://registry-npm.ywwl.com/any-signal/download/any-signal-1.2.0.tgz","fileCount":6,"unpackedSize":5266,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfO7LFCRA9TVsSAnZWagAA7GkP/1hPGZmMpOqe8d/VXpWz\nWLRyQTYFISEuD2g2oEzxxOFm65+PgZ4nwSIB9ebJpx+ktSqAcaydRFD4+Xed\nwk/jAA/vWYTtzlj/iloEpSXANMAe4KDG62jdQKgdJleDPAKoegOQabrycbdK\nrzrVqn1/VGTAhIdwQXjHFmVoKL8hksV9ZFC3dIH7sL/44+ZIXgsdtRZnV3Q3\npffsHP+3gFCsEr5z4UsOzJo82kkAbKE/OtvatSG7n5Qe340tI+JwRx4MFJMT\nslnLQrcNbIpu8xPhRRVuma4M9+ysIC+zaYvjB/01UBUmMBzyA/nRheBLBR7A\nf2eq6f1fukLnsSYvrCypic9t/ZMiRL+V6aYOeVWo1P37xOw7AqZ+PAuzlRLY\np9R+wpea9KrxkELQi07Y1aTSBOyXuaM6F5AnWPryZwVa1CFwki249CaY1XSh\ntT6gsu9H1zUKoQ1wXfKfDMB4WMV2bYPSWvqToyLIZVe087Ld/DTMHxbyhEcK\nDJ4aQEgneh40uLCnvlf+iUHaUki4DvCpER+FRx/oeO94SS+qDegBrdCcjzyW\nJn2JIskm7XSgY1Bm2uEExRpaVd9oPxZprxk7hfM3nsB+Ek95l27esYEZ+2BS\n7dcdkmwHoDc5bohBZsYhGWNUCK3izXkwKy/XRt5ZDSd+WLzu2fA6p1qSld0k\ntPcE\r\n=ZkWp\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF2VHdIk46uBtuUd9HKg1Kv4hUscgjfZ9Bdj/F8hDmQAAiEAjUKBzCIDR8/QdcO4tMm0DE3IqiUPM9Wv1b6qk9oblqA="}],"size":2432,"noattachment":false,"key":"/any-signal/-/any-signal-1.2.0.tgz"},"maintainers":[{"name":"jacobheun","email":"jacobheun@gmail.com"}],"_npmUser":{"name":"jacobheun","email":"jacobheun@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/any-signal_1.2.0_1597747908774_0.8376899452618669"},"_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":1597747908909,"_cnpm_publish_time":1597747908909,"dist-tags":{"latest":"4.2.0"}}