{"name":"timeout-abort-controller","version":"3.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":{"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":"605ca885d95631124ceaca3016c6c69f9966665e","_id":"timeout-abort-controller@3.0.0","_nodeVersion":"16.10.0","_npmVersion":"7.24.0","dist":{"integrity":"sha512-O3e+2B8BKrQxU2YRyEjC/2yFdb33slI22WRdUaDx6rvysfi9anloNZyR2q0l6LnePo5qH7gSM7uZtvvwZbc2yA==","shasum":"dd57ffca041652c03769904f8d95afd93fb95595","tarball":"http://registry-npm.ywwl.com/timeout-abort-controller/download/timeout-abort-controller-3.0.0.tgz","fileCount":5,"unpackedSize":5907,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh3rtQCRA9TVsSAnZWagAAtkcP/jE4UvFVlCfxv9qd3nqr\niYGBcoHvETlM+yez5yFPLwDSfKzZdU0FV8gsebkFa2QtmYt9nfRpQ73ujXDW\nvK/X/2V4rbkP/VvBPUOFPxyNFA+CbIGIfzOx48x951PkfFNrEfOZmbmj1q3f\nWDXvgQj9VJdSIvyaoHp+hsGvOOkLOu+su9OFMPfoYW1HZwu1mpQfv7x9UkYi\nrB5ThgBoQt9d6ic1CCCSAqiX3lvBjfpYp/E8cqUd91fbUcmdFRcUXtcBEQ5u\nQY+bTUoBPRWs8ETruv5irYv8uNSTgyMkWSMbY/w61xMkrMYdpDDRyF9RBdOF\nO7H1JSuGGMAsKyiNxcaLf0PYVJ9304HAdlyV4wQltouUzsPS31SYkTzj+Bj5\n/J/oDq9xvJY52YIG93Cbi3Pn/d6FoWV/vzIf4yXeDjtbNe16BoXMfJqIioH2\nIaiiyhe7WIuAwMUe1OO28/hdbq4ujcNyJIhPyApQFDofQnwrGo39ytS7dUj7\nfr3Sdc2L9g0dv9Z6yFssfJK1rrgDOcRuVNG/o6hGZUf7uQzVABm3/Dz6EvSc\nIML90q6+gO4ye1QO7Y6z2mjrdPUZVkpY4Dutqv6A3lcIHAV3wsEza/zcjFRc\nOu02mu6vhtIXtVjuqtqCW6a9bROt4GyAikYqjz/BLUgJMocResufIg7Hc91B\nW2Wn\r\n=SHdL\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA/JMcaTpDCHhcG7BL3chUIl4SgHp/qwwJ+3lAh3bN1dAiAzoD1RNRXWHP9DSwmDRNGMjAhF7CbV1m+8xYS+mnECiQ=="}],"size":2575,"noattachment":false,"key":"/timeout-abort-controller/-/timeout-abort-controller-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/timeout-abort-controller_3.0.0_1641986896800_0.5078414958027704"},"_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":1641986896947,"_cnpm_publish_time":1641986896947,"dist-tags":{"latest":"3.0.0"}}