{"_id":"@async-generators/terminator","_rev":"6-b5794a040e5b1750b965adcf65b10860","name":"@async-generators/terminator","description":"inform an iterator when it is prematurely terminated by the consumer.","dist-tags":{"latest":"0.4.0"},"versions":{"0.1.0":{"name":"@async-generators/terminator","description":"inform an iterator when it is prematurely terminated by the consumer.","version":"0.1.0","author":{"name":"Meirion Hughes","email":"crakinshot@yahoo.com","url":"https://github.com/MeirionHughes"},"keywords":["async","iterator","generator","esnext","typescript","linq"],"license":"MIT","main":"./dist/commonjs/index.js","typings":"./dist/commonjs/index.d.ts","module":"./dist/es2015/index.js","repository":{"type":"git","url":"git+https://github.com/async-generators/terminator.git"},"bugs":{"url":"https://github.com/async-generators/terminator/issues"},"devDependencies":{"@async-generators/equal":"^0.2.1","@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node":"^8.0.28","chai":"^4.1.2","chai-as-promised":"^7.1.1","codecov":"^2.3.0","mocha":"^3.5.3","nyc":"^11.2.1","ts-node":"^3.3.0","typescript":"^2.5.2"},"scripts":{"test":"nyc node_modules/mocha/bin/mocha --harmony-async-iteration --require source-map-support/register --compilers ts:ts-node/register test/*.ts","build":"npm run build:commonjs && npm run build:es2015","build:commonjs":"tsc --project tsconfig.build.json --rootDir src/ --outDir ./dist/commonjs","build:es2015":"tsc --project tsconfig.build.json --rootDir src/ --outDir ./dist/es2015 --module es2015","cover":"codecov"},"engines":{"node":">=8.5.0"},"nyc":{"exclude":["node_modules/","test/","coverage/"],"extension":[".ts"],"require":["ts-node/register"],"reporter":["text-summary","lcov"],"sourceMap":true,"instrument":true},"dependencies":{"events":"^1.1.1"},"gitHead":"26e682ad5adb13bb0c8d84a3aa986917937b26dc","homepage":"https://github.com/async-generators/terminator#readme","_id":"@async-generators/terminator@0.1.0","_npmVersion":"5.3.0","_nodeVersion":"8.5.0","_npmUser":{"name":"meirionhughes","email":"crakinshot@yahoo.com"},"dist":{"integrity":"sha512-IIkAOenXQ5k1F3NgNouwUwALyfCDDxIoO5oNW+CtS5mQ8ejpL4PHLJuUjhPKTWYNbeS7DknBsUpGH13phauuPw==","shasum":"e7cb68694521d368679ce682d60a6e5fe380aa23","tarball":"https://registry.npmjs.org/@async-generators/terminator/-/terminator-0.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDpMxku6gqGxdXi2K+h6EvEdbaV5+R/f5VfgP7QuYcX6AIgbVMEMDzmvB3o/zZf7wvSg2RDHRdlQIrTab1DYOR/K+M="}]},"maintainers":[{"name":"meirionhughes","email":"crakinshot@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/terminator-0.1.0.tgz_1506423809660_0.43146427581086755"}},"0.1.1":{"name":"@async-generators/terminator","description":"inform an iterator when it is prematurely terminated by the consumer.","version":"0.1.1","author":{"name":"Meirion Hughes","email":"crakinshot@yahoo.com","url":"https://github.com/MeirionHughes"},"keywords":["async","iterator","generator","esnext","typescript","linq"],"license":"MIT","main":"./dist/commonjs/index.js","typings":"./dist/commonjs/index.d.ts","module":"./dist/es2015/index.js","repository":{"type":"git","url":"git+https://github.com/async-generators/terminator.git"},"bugs":{"url":"https://github.com/async-generators/terminator/issues"},"devDependencies":{"@async-generators/equal":"^0.2.1","@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node":"^8.0.28","chai":"^4.1.2","chai-as-promised":"^7.1.1","codecov":"^2.3.0","mocha":"^3.5.3","nyc":"^11.2.1","ts-node":"^3.3.0","typescript":"^2.5.2"},"scripts":{"test":"nyc node_modules/mocha/bin/mocha --harmony-async-iteration --require source-map-support/register --compilers ts:ts-node/register test/*.ts","build":"npm run build:commonjs && npm run build:es2015","build:commonjs":"tsc --project tsconfig.build.json --rootDir src/ --outDir ./dist/commonjs","build:es2015":"tsc --project tsconfig.build.json --rootDir src/ --outDir ./dist/es2015 --module es2015","cover":"codecov"},"engines":{"node":">=8.5.0"},"nyc":{"exclude":["node_modules/","test/","coverage/"],"extension":[".ts"],"require":["ts-node/register"],"reporter":["text-summary","lcov"],"sourceMap":true,"instrument":true},"dependencies":{},"gitHead":"4378fcd46e50fbe3ad66dec86e3f15a8b0787b66","homepage":"https://github.com/async-generators/terminator#readme","_id":"@async-generators/terminator@0.1.1","_npmVersion":"5.3.0","_nodeVersion":"8.5.0","_npmUser":{"name":"meirionhughes","email":"crakinshot@yahoo.com"},"dist":{"integrity":"sha512-/6ziRrOaoOtVBKYl/zqnJUrtDHEQ691OXoGQI1zES5J/War1T8NcuqNy0ltxZeeMAVBoHlJTEimkwypyfIixbg==","shasum":"fe251105d50b401c886b77be43c002c7288a345b","tarball":"https://registry.npmjs.org/@async-generators/terminator/-/terminator-0.1.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCTI3DKwA1XMkldNzteXaHcBW7rdFRME+CV2fKhsAMDLAIgOmTQk2E9RNseDKzsuafNKeUyUEAOwCFCHyuzXYLN8To="}]},"maintainers":[{"name":"meirionhughes","email":"crakinshot@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/terminator-0.1.1.tgz_1506424351217_0.691895505413413"}},"0.2.0":{"name":"@async-generators/terminator","description":"inform an iterator when it is prematurely terminated by the consumer.","version":"0.2.0","author":{"name":"Meirion Hughes","email":"crakinshot@yahoo.com","url":"https://github.com/MeirionHughes"},"keywords":["async","iterator","generator","esnext","typescript","linq"],"license":"MIT","main":"./dist/commonjs/index.js","typings":"./dist/commonjs/index.d.ts","module":"./dist/es2015/index.js","repository":{"type":"git","url":"git+https://github.com/async-generators/terminator.git"},"bugs":{"url":"https://github.com/async-generators/terminator/issues"},"devDependencies":{"@async-generators/equal":"^0.2.1","@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node":"^8.0.28","chai":"^4.1.2","chai-as-promised":"^7.1.1","codecov":"^2.3.0","mocha":"^3.5.3","nyc":"^11.2.1","ts-node":"^3.3.0","typescript":"^2.5.2"},"scripts":{"test":"nyc node_modules/mocha/bin/mocha --harmony-async-iteration --require source-map-support/register --compilers ts:ts-node/register test/*.ts","build":"npm run build:commonjs && npm run build:es2015","build:commonjs":"tsc --project tsconfig.build.json --rootDir src/ --outDir ./dist/commonjs","build:es2015":"tsc --project tsconfig.build.json --rootDir src/ --outDir ./dist/es2015 --module es2015","cover":"codecov"},"engines":{"node":">=8.5.0"},"nyc":{"exclude":["node_modules/","test/","coverage/"],"extension":[".ts"],"require":["ts-node/register"],"reporter":["text-summary","lcov"],"sourceMap":true,"instrument":true},"dependencies":{},"gitHead":"026833eff681f07cb487cc72cca1155a9ac949f2","homepage":"https://github.com/async-generators/terminator#readme","_id":"@async-generators/terminator@0.2.0","_npmVersion":"5.3.0","_nodeVersion":"8.5.0","_npmUser":{"name":"meirionhughes","email":"crakinshot@yahoo.com"},"dist":{"integrity":"sha512-2tja9c82x0yuJ4a+LEztebGDSuPPvoFVrrQyYoLrwbx5b9ca8RFI63Gj7nb9v58pDcVtQA5r0NQyEma6RCzUBw==","shasum":"ee7195e1237a5f85702f64dad8450e558badee11","tarball":"https://registry.npmjs.org/@async-generators/terminator/-/terminator-0.2.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGMm8jVHHXbb4/DzXQUg+UwRwpBSp9VXcdvTd0n6HFG6AiEAiX/mR4bWcJg4A42bQulMk5xrRGK7b0uRZ7OizowgvTs="}]},"maintainers":[{"name":"meirionhughes","email":"crakinshot@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/terminator-0.2.0.tgz_1506439317043_0.8307663972955197"}},"0.3.0":{"name":"@async-generators/terminator","description":"inform an iterator when it is prematurely terminated by the consumer.","version":"0.3.0","author":{"name":"Meirion Hughes","email":"crakinshot@yahoo.com","url":"https://github.com/MeirionHughes"},"keywords":["async","iterator","generator","esnext","typescript","linq"],"license":"MIT","main":"./dist/commonjs/index.js","typings":"./dist/commonjs/index.d.ts","module":"./dist/es2015/index.js","repository":{"type":"git","url":"git+https://github.com/async-generators/terminator.git"},"bugs":{"url":"https://github.com/async-generators/terminator/issues"},"devDependencies":{"@async-generators/equal":"^0.6.0","@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node":"^8.0.28","chai":"^4.1.2","chai-as-promised":"^7.1.1","codecov":"^2.3.0","mocha":"^3.5.3","nyc":"^11.2.1","ts-node":"^3.3.0","typescript":"^2.5.2"},"scripts":{"test":"nyc node_modules/mocha/bin/mocha --require source-map-support/register --compilers ts:ts-node/register test/*.ts","build":"npm run build:commonjs && npm run build:es2015","build:commonjs":"tsc --project tsconfig.build.json --rootDir src/ --outDir ./dist/commonjs","build:es2015":"tsc --project tsconfig.build.json --rootDir src/ --outDir ./dist/es2015 --module es2015","cover":"codecov"},"engines":{"node":">=8.5.0"},"nyc":{"exclude":["node_modules/","test/","coverage/"],"extension":[".ts"],"require":["ts-node/register"],"reporter":["text-summary","lcov"],"sourceMap":true,"instrument":true},"dependencies":{},"gitHead":"42298a057733e892b071188e9c549ca0b6a51a3b","homepage":"https://github.com/async-generators/terminator#readme","_id":"@async-generators/terminator@0.3.0","_npmVersion":"5.4.2","_nodeVersion":"8.7.0","_npmUser":{"name":"meirionhughes","email":"crakinshot@yahoo.com"},"dist":{"integrity":"sha512-8MpkTlzXbl2LIV6mj1+0Fkzl5Dw0LzW/p/SM3Bp8WqBuIsxlAoCz4FLtRu5F2640DEX8a9l9ABHkzM5G7OZgBQ==","shasum":"1bbd86c4afd0a56e49123289a6897fff762dcea6","tarball":"https://registry.npmjs.org/@async-generators/terminator/-/terminator-0.3.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAqSMkWIO6f/w/qeferYZY4VB7b7WazImOGeXCm8KGQCAiAHsqg48vhEw+JWorUamPJNAYpgLWEmpXmDbYJRWS3nkw=="}]},"maintainers":[{"name":"meirionhughes","email":"crakinshot@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/terminator-0.3.0.tgz_1515769540689_0.3877131927292794"}},"0.3.1":{"name":"@async-generators/terminator","description":"inform an iterator when it is prematurely terminated by the consumer.","version":"0.3.1","author":{"name":"Meirion Hughes","email":"crakinshot@yahoo.com","url":"https://github.com/MeirionHughes"},"keywords":["async","iterator","generator","esnext","typescript","linq"],"license":"MIT","main":"./dist/commonjs/index.js","typings":"./dist/commonjs/index.d.ts","module":"./dist/es2015/index.js","repository":{"type":"git","url":"git+https://github.com/async-generators/terminator.git"},"bugs":{"url":"https://github.com/async-generators/terminator/issues"},"devDependencies":{"@async-generators/equal":"^0.6.0","@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node":"^8.0.28","chai":"^4.1.2","chai-as-promised":"^7.1.1","codecov":"^2.3.0","mocha":"^3.5.3","nyc":"^11.2.1","ts-node":"^3.3.0","typescript":"^2.5.2"},"scripts":{"test":"nyc node_modules/mocha/bin/mocha --require source-map-support/register --compilers ts:ts-node/register test/*.ts","build":"npm run build:commonjs && npm run build:es2015","build:commonjs":"tsc --project tsconfig.build.json --rootDir src/ --outDir ./dist/commonjs","build:es2015":"tsc --project tsconfig.build.json --rootDir src/ --outDir ./dist/es2015 --module es2015","cover":"codecov"},"engines":{"node":">=8.5.0"},"nyc":{"exclude":["node_modules/","test/","coverage/"],"extension":[".ts"],"require":["ts-node/register"],"reporter":["text-summary","lcov"],"sourceMap":true,"instrument":true},"dependencies":{},"gitHead":"afe9a258c0598b891c4eefefe700b8b893048653","homepage":"https://github.com/async-generators/terminator#readme","_id":"@async-generators/terminator@0.3.1","_npmVersion":"5.4.2","_nodeVersion":"8.7.0","_npmUser":{"name":"meirionhughes","email":"crakinshot@yahoo.com"},"dist":{"integrity":"sha512-59XMMlb7WvLnm68c/pTKcvBK0zrHbQiR57DvGGKRiVD53tiKigIQPkgHi1IUbRzQ9LZQjR1snEe0UgkFQy3iTw==","shasum":"323866ae30236fc08f1ff2bf27693521d8640655","tarball":"https://registry.npmjs.org/@async-generators/terminator/-/terminator-0.3.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCxW9VQ0Oxv8XJy/91pziFsZbDnG1u0brQS4iVscetA0AIgdWeZrcXiLubp3dECwt0lKnrZ5YqLWBkd+u2OCa/MdpU="}]},"maintainers":[{"name":"meirionhughes","email":"crakinshot@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/terminator-0.3.1.tgz_1515773569337_0.6914311361033469"}},"0.4.0":{"name":"@async-generators/terminator","description":"inform an iterator when it is prematurely terminated by the consumer.","version":"0.4.0","author":{"name":"Meirion Hughes","email":"crakinshot@yahoo.com","url":"https://github.com/MeirionHughes"},"keywords":["async","iterator","generator","esnext","typescript","linq"],"license":"MIT","main":"./dist/commonjs/index.js","typings":"./dist/commonjs/index.d.ts","module":"./dist/es2015/index.js","repository":{"type":"git","url":"git+https://github.com/async-generators/terminator.git"},"bugs":{"url":"https://github.com/async-generators/terminator/issues"},"devDependencies":{"@async-generators/equal":"^0.7.0","@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node":"^8.0.28","chai":"^4.1.2","chai-as-promised":"^7.1.1","codecov":"^2.3.0","mocha":"^3.5.3","nyc":"^11.2.1","ts-node":"^3.3.0","typescript":"^2.5.2"},"scripts":{"test":"nyc node_modules/mocha/bin/mocha --harmony test/*.ts","build":"npm run build:commonjs && npm run build:es2015","build:commonjs":"tsc --project tsconfig.build.json --rootDir src/ --outDir ./dist/commonjs --module commonjs","build:es2015":"tsc --project tsconfig.build.json --rootDir src/ --outDir ./dist/es2015 --module es2015","cover":"codecov"},"engines":{"node":">=9.0.0"},"nyc":{"exclude":["node_modules/","test/","coverage/"],"extension":[".ts"],"require":["source-map-support/register","ts-node/register"],"reporter":["text-summary","lcov"],"sourceMap":true,"instrument":true},"dependencies":{},"gitHead":"af2e31b30fbfedbe5f15a5fa17d83830d47d7575","homepage":"https://github.com/async-generators/terminator#readme","_id":"@async-generators/terminator@0.4.0","_npmVersion":"5.6.0","_nodeVersion":"9.4.0","_npmUser":{"name":"meirionhughes","email":"crakinshot@yahoo.com"},"dist":{"integrity":"sha512-Kj08FqHgdx4QZ1mwJrlN3L2MWNNWHHWSQezfClxMUvGU1pYjoRa/4Yev1U/2Y71aqDDXEYC7pr13HNv7Un7Kog==","shasum":"a2aa109337fdea375905b8df8596376ab237bbc0","tarball":"https://registry.npmjs.org/@async-generators/terminator/-/terminator-0.4.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA1/47LoQtUIDkjzlst8HYjQWgNCKgQTdBb/NARipiDGAiAXIxyCKvK0+n0i7CLFJSE1X/yiE3pVBNHqhHnopPe/Hg=="}]},"maintainers":[{"name":"meirionhughes","email":"crakinshot@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/terminator-0.4.0.tgz_1516116061629_0.5814504611771554"}}},"readme":"# terminator\n[![logo](https://avatars1.githubusercontent.com/u/31987273?v=4&s=110)][async-url]\n\ninform an iterable when it is prematurely terminated by the consumer. \n\n[![NPM version][npm-image]][npm-url]\n[![Travis Status][travis-image]][travis-url]\n[![Travis Status][codecov-image]][codecov-url]\n\n### Install\n```\nyarn add @async-generators/terminator\n```\n\nThis package's `main` entry points to a `commonjs` dist. \nThe `module` entry points to a `es2015` module dist. Both require require native async-generator support, or be down-compiled with a webpack loader. \n\n## Api\n\n### terminator(source)\n\n<code>terminator()</code> returns an iterable that, when iterated, wraps the source iterable and captures calls to `return`. When a compliant consumer (`for`, `for-await`) terminates iteration, then the `return` call is rerouted to call `next(Symbol.for(\"terminated\"))`. The original `source` iterable can then find out if it was terminated by examining the return value of `yield` to see if it equals `Symbol.for(\"terminated\")`;\n\nsource must have a `[Symbol.asyncIterator]` or `[Symbol.iterator]` property. If both are present only `[Symbol.asyncIterator]` is used. \n\n## Example\n\nexample.js\n```js\nconst terminator = require(\"@async-generators/terminator\").default;\n\nasync function* source() {\n  for (let i = 0; i < 10; i++) {\n    let terminated = (yield i) == Symbol.for(\"terminated\");\n    if (terminated) {\n      console.log(\"clean-up on aisle five!\");\n      return;\n    }\n  }\n}\n\nasync function main(){\n  for await (let item of terminator(source())){\n    if(item > 4){\n      break;\n    }\n    console.log(item);\n  }\n}\n\nmain().catch(console.log);\n```\n\nExecute with the latest node.js: \n\n```\nnode --harmony-async-iteration example.js\n```\n\noutput:\n```\n0\n1\n2\n3\n4\nclean-up on aisle five!\n```\n## Typescript\n\nThis library is fully typed and can be imported using: \n\n```ts\nimport terminator from '@async-generators/terminator');\n```\n\nIt is also possible to directly execute your [properly configured](https://stackoverflow.com/a/43694282/1657476) typescript with [ts-node](https://www.npmjs.com/package/ts-node):\n\n```\nts-node --harmony_async_iteration example.ts\n```\n\n[npm-url]: https://npmjs.org/package/@async-generators/terminator\n[npm-image]: https://img.shields.io/npm/v/@async-generators/terminator.svg\n[npm-downloads]: https://img.shields.io/npm/dm/@async-generators/terminator.svg\n[travis-url]: https://travis-ci.org/async-generators/terminator\n[travis-image]: https://img.shields.io/travis/async-generators/terminator/master.svg\n[codecov-url]: https://codecov.io/gh/async-generators/terminator\n[codecov-image]: https://codecov.io/gh/async-generators/terminator/branch/master/graph/badge.svg\n[async-url]: https://github.com/async-generators","maintainers":[{"name":"meirionhughes","email":"crakinshot@yahoo.com"}],"time":{"modified":"2022-04-04T16:01:22.639Z","created":"2017-09-26T11:03:30.800Z","0.1.0":"2017-09-26T11:03:30.800Z","0.1.1":"2017-09-26T11:12:32.154Z","0.2.0":"2017-09-26T15:21:58.512Z","0.3.0":"2018-01-12T15:05:41.611Z","0.3.1":"2018-01-12T16:12:50.231Z","0.4.0":"2018-01-16T15:21:03.307Z"},"homepage":"https://github.com/async-generators/terminator#readme","keywords":["async","iterator","generator","esnext","typescript","linq"],"repository":{"type":"git","url":"git+https://github.com/async-generators/terminator.git"},"author":{"name":"Meirion Hughes","email":"crakinshot@yahoo.com","url":"https://github.com/MeirionHughes"},"bugs":{"url":"https://github.com/async-generators/terminator/issues"},"license":"MIT","readmeFilename":"README.md"}