{"name":"any-signal","version":"1.1.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","dependencies":{"abort-controller":"^3.0.0"},"devDependencies":{"ava":"^2.4.0","nyc":"^14.1.1","p-defer":"^3.0.0","standard":"^14.3.1"},"ava":{"babel":false,"compileEnhancements":false,"failWithoutAssertions":false},"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":"a611f3014033fd43ec522289b1abe3d9698fc27f","_id":"any-signal@1.1.0","_nodeVersion":"12.13.0","_npmVersion":"6.12.0","dist":{"integrity":"sha512-mtwqpy58ys+/dRdH5Z8VArUluVrfz9/5BXo8tvSZ9kcQr3k9yyOPnGrYCBJQfcC5IlMrr63kDBlf5GyQCFn+Fw==","shasum":"8e43cd0ae03266261d5061595ecf8aaad1828872","tarball":"http://registry-npm.ywwl.com/any-signal/download/any-signal-1.1.0.tgz","fileCount":4,"unpackedSize":4807,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd74hrCRA9TVsSAnZWagAAiGIP/2wxCVHy3Pjk7CoSj1gM\nlSDKqbdh4pUb+WQYcG1hl+xhzgwEKyI4RVSGEFEVZkaQcBl57QepOX53AC7f\ntbjZQddLb08z9YcoBG4PlDXnSxwN6IqqepkMf42rSd1xYyAX7JUcgfLoPtVQ\n9SLnbNxo3Ntw3o6IDkoODKWjjzAIvOjb4dNuXbeIkLYh1xzVjD84/OQTQ0Xg\nS/PioNw3mYa6i0TEBbhS1maSc3JfynWzGz0z3NFXPNPOy0E6Jr7OLHlaJ/em\n3Bh+Dzz7+H4vNTxBJHSqg72loIk4SAfOg4/gMrF0uUNHzV0EpPdf/uWY97wp\nt548yJZpN0d6EfttKliHrEadJNHG9WPGkTlmo33eu6j2PWy4PbyEGmdb48sI\nNw7XQJV68oGqdpcIdvjVBAPmwdaUdAFnAMmR11I2C78zOF5ozBsPNAWXt65U\nfbDITEzCqISDw3/N5SlmmwWdaQyt9yfgZ6b/Ko7LjGv0peDVNpqin4FDmkP7\nKWFejUQsPZLPv2HlvLUeqh0Z92OLhdX/akZOyfqstrvLEXFnKvG/fDOKabgE\n2Jj0WJFIIgLQ5Xves2q3QSbUA6tuD/QnXJigV6gFmUh7POMjuTcsV8nybBiB\nUv9Ij+gtaE0jm3tIOHm46NXhmLNFzikhWPyKf5okyF0cpJTAPAuD3DpfVZcG\nupMH\r\n=mezP\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH0CWTEUkdHvxQn5TIRIKGTz2XQ0mmEHzdex50PTpeNiAiEAyISD3NPulhThFpXRum9/szKJ2kkJrHFGdzOWcC9M9yk="}],"size":2226,"noattachment":false,"key":"/any-signal/-/any-signal-1.1.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.1.0_1575979114967_0.26275796107593097"},"_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":1575979115107,"_cnpm_publish_time":1575979115107,"dist-tags":{"latest":"4.2.0"}}