{"name":"timeout-abort-controller","version":"1.0.0","description":"An AbortController that aborts after a specified timeout","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","retimer":"^2.0.0"},"devDependencies":{"ava":"^2.4.0","delay":"^4.3.0","nyc":"^14.1.1","standard":"^14.3.1"},"ava":{"babel":false,"compileEnhancements":false,"failWithoutAssertions":false},"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","gitHead":"2916b50f4c93cee0f2502abe34638408b2890eea","_id":"timeout-abort-controller@1.0.0","_nodeVersion":"12.13.0","_npmVersion":"6.12.0","dist":{"integrity":"sha512-pzJMQutdN6kkO2H+MkyH4kbi+ij3ja8zlPwPOi4ulnilmwo4kuXwsS3amULGnHtEKmQMUc3PJ1HwliegyMg04Q==","shasum":"bc39ce4f60eadb499a380b1a867d420f47fb4bff","tarball":"http://registry-npm.ywwl.com/timeout-abort-controller/download/timeout-abort-controller-1.0.0.tgz","fileCount":4,"unpackedSize":4662,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd74g1CRA9TVsSAnZWagAAdLAP/iC/E8l4o06USng7VORl\nsL/JNd2XkNYCV97/fuvGqwaGBmhWQ1uoCfseTwa/82qIdOG76d7//uTRvCEA\nhXj0pq0aHuBqUkR4w6lWnMeJL3nKANG83h0BgrrxqDNJ/1PirMVcJRTvUkXc\nhaUnIUuif3fGBKLZ9Z2TGjmNiXu5UXlCWc9Ss39RDKYVpBXfyDdN40S5imKN\nQFSxpYFAYgYEA4JWx+aI3dc64Ns4JOq4ImXPg99UXGe7rW/PM7RRK5Q7cAkV\nPMjMtbzcti03pKyV/9MqBuHownHPmEbgLfkinUz8xl1IK2XqhmraV5zxe5L7\nd4yfls+KeHBuuEffu5JtNcgenNmCYUq+G3hCmZmA6fIJ4HI9z7jz+7vhchol\nwKdpj75RPqOoCe5i+UCpAaJL8UFf0ug+K3tN/X6R0NHOqueQ9+c8DXltKHA2\neLw0OsqMwwG8/dXOvt7+OWmA91wtRqCGqVbP77mYm5gjcNcTjHmzVeidCM84\nTfM/kFLKRbaIwZ7V56LG4LvyGltGU+no1csahXSD2eBnAkL0Zeub5fGzmot3\nKkrg4laDzlMt4j3FMKJZ81tpYav1eYQNKobOba5C1W3GyfQZ/IkS7GDlWhph\nQSVEcIj0IUxQXybdaOTDSpGZk8S7zMQUPzVYX1oqrKALkYOz4djMwn0QNRwv\nE4/j\r\n=CX+i\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCErOUTzeFU155EDlmsDQXBeTRlSeAwS8mOAk1TodZRbAIgfkN1ITRq0jFpkYoMZPUndrquN9KlXdXfMQkNECwgc+Q="}],"size":2182,"noattachment":false,"key":"/timeout-abort-controller/-/timeout-abort-controller-1.0.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/timeout-abort-controller_1.0.0_1575979061271_0.5207121912907451"},"_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":1575979061432,"_cnpm_publish_time":1575979061432,"dist-tags":{"latest":"3.0.0"}}