{"name":"race-signal","version":"2.0.2","description":"Race a promise against an AbortSignal","author":{"name":"Alex Potsides","email":"alex@achingbrain.net"},"license":"Apache-2.0 OR MIT","homepage":"https://github.com/achingbrain/race-signal#readme","repository":{"type":"git","url":"git+https://github.com/achingbrain/race-signal.git"},"bugs":{"url":"https://github.com/achingbrain/race-signal/issues"},"publishConfig":{"access":"public","provenance":true},"type":"module","types":"./dist/src/index.d.ts","exports":{".":{"types":"./dist/src/index.d.ts","import":"./dist/src/index.js","module-sync":"./dist/src/index.js"}},"release":{"branches":["main"],"plugins":[["@semantic-release/commit-analyzer",{"preset":"conventionalcommits","releaseRules":[{"breaking":true,"release":"major"},{"revert":true,"release":"patch"},{"type":"feat","release":"minor"},{"type":"fix","release":"patch"},{"type":"docs","release":"patch"},{"type":"test","release":"patch"},{"type":"deps","release":"patch"},{"scope":"no-release","release":false}]}],["@semantic-release/release-notes-generator",{"preset":"conventionalcommits","presetConfig":{"types":[{"type":"feat","section":"Features"},{"type":"fix","section":"Bug Fixes"},{"type":"chore","section":"Trivial Changes"},{"type":"docs","section":"Documentation"},{"type":"deps","section":"Dependencies"},{"type":"test","section":"Tests"}]}}],"@semantic-release/changelog","@semantic-release/npm","@semantic-release/github",["@semantic-release/git",{"assets":["CHANGELOG.md","package.json"]}]]},"scripts":{"clean":"aegir clean","lint":"aegir lint","build":"aegir build","test":"aegir test","test:node":"aegir test -t node --cov","test:chrome":"aegir test -t browser --cov","test:chrome-webworker":"aegir test -t webworker","test:firefox":"aegir test -t browser -- --browser firefox","test:firefox-webworker":"aegir test -t webworker -- --browser firefox","release":"aegir release","dep-check":"aegir dep-check","docs":"aegir docs"},"devDependencies":{"aegir":"^48.1.2"},"gitHead":"482de082caedf989d1e41d283277505785ae60fc","_id":"race-signal@2.0.2","_nodeVersion":"24.19.0","_npmVersion":"11.19.0","dist":{"integrity":"sha512-IuNNNY5NLriMFEGl3BVei2xq9NIcpkuAklhPWamhu5tRJrJz0w9sloUMz73YXpmUluE2EZocmJm9rpQqXmCPiA==","shasum":"be5ddd1fc6bd44663772a67ff7c6bdfa1e99c90a","tarball":"http://registry-npm.ywwl.com/race-signal/download/race-signal-2.0.2.tgz","fileCount":10,"unpackedSize":19689,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/race-signal@2.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHtrdpcROjdZ9H6Q/ugIPfTGD38+UDiPuQswqdtq9uDeAiBfM6vPe3tqh5H38PjRQiC5ZqcBu1YccudhJBQfuar/8Q=="}],"size":4836,"noattachment":false,"key":"/race-signal/-/race-signal-2.0.2.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:838a849e-ccda-40d3-9e6d-823643bf5634"}},"directories":{},"maintainers":[{"name":"achingbrain","email":"alex@achingbrain.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/race-signal_2.0.2_1786868457839_0.5440567317827512"},"_hasShrinkwrap":false,"readme":"# race-signal\n\n[![codecov](https://img.shields.io/codecov/c/github/achingbrain/race-signal.svg?style=flat-square)](https://codecov.io/gh/achingbrain/race-signal)\n[![CI](https://img.shields.io/github/actions/workflow/status/achingbrain/race-signal/js-test-and-release.yml?branch=main\\&style=flat-square)](https://github.com/achingbrain/race-signal/actions/workflows/js-test-and-release.yml?query=branch%3Amain)\n\n> Race a promise against an AbortSignal\n\n# About\n\n<!--\n\n!IMPORTANT!\n\nEverything in this README between \"# About\" and \"# Install\" is automatically\ngenerated and will be overwritten the next time the doc generator is run.\n\nTo make changes to this section, please update the @packageDocumentation section\nof src/index.js or src/index.ts\n\nTo experiment with formatting, please run \"npm run docs\" from the root of this\nrepo and examine the changes made.\n\n-->\n\nPass a promise and an abort signal and await the result.\n\n## Example - Basic usage\n\n```ts\nimport { raceSignal } from 'race-signal'\n\nconst controller = new AbortController()\n\nconst promise = new Promise((resolve, reject) => {\n  setTimeout(() => {\n    resolve('a value')\n  }, 1000)\n})\n\nsetTimeout(() => {\n  controller.abort()\n}, 500)\n\n// throws an AbortError\nconst resolve = await raceSignal(promise, controller.signal)\n```\n\n## Example - Overriding errors\n\nBy default the thrown error is the `.reason` property of the signal but it's\npossible to override this behaviour with the `translateError` option:\n\n```ts\nimport { raceSignal } from 'race-signal'\n\nconst controller = new AbortController()\n\nconst promise = new Promise((resolve, reject) => {\n  setTimeout(() => {\n    resolve('a value')\n  }, 1000)\n})\n\nsetTimeout(() => {\n  controller.abort()\n}, 500)\n\n// throws `Error('Oh no!')`\nconst resolve = await raceSignal(promise, controller.signal, {\n  translateError: (signal) => {\n    // use `signal`, or don't\n    return new Error('Oh no!')\n  }\n})\n```\n\n# Install\n\n```console\n$ npm i race-signal\n```\n\n## Browser `<script>` tag\n\nLoading this module through a script tag will make its exports available as `RaceSignal` in the global namespace.\n\n```html\n<script src=\"https://unpkg.com/race-signal/dist/index.min.js\"></script>\n```\n\n# API Docs\n\n- <https://achingbrain.github.io/race-signal>\n\n# License\n\nLicensed under either of\n\n- Apache 2.0, ([LICENSE-APACHE](https://github.com/achingbrain/race-signal/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)\n- MIT ([LICENSE-MIT](https://github.com/achingbrain/race-signal/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":1786868457972,"_cnpm_publish_time":1786868457972,"dist-tags":{"latest":"2.0.2"}}