{"name":"timeout-abort-controller","version":"2.0.0","description":"An AbortController that aborts after a specified timeout","main":"index.js","scripts":{"test":"npm run lint && nyc --reporter=lcov --reporter=text tape test.js","test:browser":"npm run test:chrome && npm run test:firefox && npm run test:webkit","test:chrome":"playwright-test test.js --browser chromium --runner tape","test:firefox":"playwright-test test.js --browser firefox --runner tape","test:webkit":"playwright-test test.js --browser webkit --runner tape","lint":"standard","prepare":"rimraf dist && tsc --emitDeclarationOnly --declarationDir dist"},"keywords":[],"author":{"name":"Jacob Heun"},"license":"MIT","dependencies":{"abort-controller":"^3.0.0","native-abort-controller":"^1.0.4","retimer":"^3.0.0"},"devDependencies":{"@types/tape":"^4.13.2","delay":"^5.0.0","nyc":"^15.0.1","playwright-test":"^7.1.0","rimraf":"^3.0.2","standard":"^16.0.3","tape":"^5.0.1","typescript":"^4.1.3"},"repository":{"type":"git","url":"git+https://github.com/jacobheun/timeout-abort-controller.git"},"bugs":{"url":"https://github.com/jacobheun/timeout-abort-controller/issues"},"homepage":"https://github.com/jacobheun/timeout-abort-controller#readme","types":"dist/index.d.ts","gitHead":"91e9ec9c602356bed91f6cb1eaf9071c7d99da61","_id":"timeout-abort-controller@2.0.0","_nodeVersion":"16.10.0","_npmVersion":"7.24.0","dist":{"integrity":"sha512-2FAPXfzTPYEgw27bQGTHc0SzrbmnU2eso4qo172zMLZzaGqeu09PFa5B2FCUHM1tflgRqPgn5KQgp6+Vex4uNA==","shasum":"d6a59209132e520413092dd4b4d71eaaf5887feb","tarball":"http://registry-npm.ywwl.com/timeout-abort-controller/download/timeout-abort-controller-2.0.0.tgz","fileCount":5,"unpackedSize":6065,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDmVSduti2VMbdDg+AvPEN3snu8Jh2g+TkbqEfq1/6bcAiAmZDn1X2BxRstcbUzonDqGTIDL9Ll1dzopX2Rx+5oK/A=="}],"size":2597,"noattachment":false,"key":"/timeout-abort-controller/-/timeout-abort-controller-2.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/timeout-abort-controller_2.0.0_1633458751594_0.7437365117594299"},"_hasShrinkwrap":false,"readme":"# timeout-abort-controller\n\n[![Build Status](https://travis-ci.com/jacobheun/timeout-abort-controller.svg?branch=master)](https://travis-ci.com/jacobheun/timeout-abort-controller) [![dependencies Status](https://david-dm.org/jacobheun/timeout-abort-controller/status.svg)](https://david-dm.org/jacobheun/timeout-abort-controller) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n> An AbortController that aborts after a specified timeout.\n\n`timeout-abort-controller` uses [`retimer`](https://github.com/mcollina/retimer) internally to help reduce the impact of having numerous timers running.\n\n## Install\n\n```\nnpm install timeout-abort-controller\n```\n\n## Usage\n\n```js\nconst { AbortController } = require('native-abort-controller')\nconst { TimeoutController } = require('timeout-abort-controller')\nconst anySignal = require('any-signal')\n\nconst userController = new AbortController()\n// Aborts after 1 second\nconst timeoutController = new TimeoutController(1000)\n\nconst combinedSignal = anySignal([userController.signal, timeoutController.signal])\ncombinedSignal.addEventListener('abort', () => console.log('Abort!'))\n\n// The user or the timeout can now abort the action\nawait performSomeAction({ signal: combinedSignal })\ntimeoutController.clear()\n```\n\n## API\n\n### `new TimeoutController(ms)`\n\nCreates an [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) compliant `TimeoutController`.\n\n#### Parameters\n\n| Name | Type | Description |\n|------|------|-------------|\n| ms | number | The time in milliseconds for when the TimeoutController should abort |\n\n### `timeoutController.clear()`\n\nClears the internal timer.\n\n### `timeoutController.abort()`\n\nAborts the controller and clears the internal timeout.\n\n### `timeoutController.reset()`\n\nClears the timer and sets the internal timeout to occur after the `ms` timeout it was created with.\n\n## Related\n\n- [`abort-controller`](https://github.com/mysticatea/abort-controller)\n- [`native-abort-controller`](https://github.com/achingbrain/native-abort-controller)\n- [`any-signal`](https://github.com/jacobheun/any-signal) Combines an array of AbortSignals into a single signal.\n\n## LICENSE\n\n[MIT](LICENSE) © Jacob Heun\n","publish_time":1633458751912,"_cnpm_publish_time":1633458751912,"dist-tags":{"latest":"3.0.0"}}