{"_id":"@async-generators/from-emitter","_rev":"4-2c352d668f335e5b680dd997fe638c6b","name":"@async-generators/from-emitter","description":"convert an event-emitter to an async-iterable ","dist-tags":{"latest":"0.3.0"},"versions":{"0.1.0":{"name":"@async-generators/from-emitter","description":"convert an event-emitter to an async-iterable ","version":"0.1.0","author":{"name":"Meirion Hughes","email":"crakinshot@yahoo.com","url":"https://github.com/MeirionHughes"},"keywords":["async","iterator","generator","esnext","typescript","linq","events"],"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/from-emitter.git"},"bugs":{"url":"https://github.com/async-generators/from-emitter/issues"},"devDependencies":{"@async-generators/equal":"^0.2.1","@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node":"^8.0.31","chai":"^4.1.2","chai-as-promised":"^7.1.1","codecov":"^2.3.0","events":"^1.1.1","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":{"@async-generators/subject":"^0.2.1","@async-generators/terminator":"^0.2.0"},"gitHead":"81d1617dcd7028584ab59a9ab4a0a8432faa568d","homepage":"https://github.com/async-generators/from-emitter#readme","_id":"@async-generators/from-emitter@0.1.0","_npmVersion":"5.0.3","_nodeVersion":"8.5.0","_npmUser":{"name":"meirionhughes","email":"crakinshot@yahoo.com"},"dist":{"integrity":"sha512-0Lq4zDuhtWhAuEhuZ4UWy2FuVgyxl0MYL5x3BA671pRx530CctsQaUdUVPEyPyYzv7tcI6uduXP2cZO6W0i7sA==","shasum":"8e610072eaf3e8b381e20773b3919f75c26336db","tarball":"https://registry.npmjs.org/@async-generators/from-emitter/-/from-emitter-0.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHBlPtCXSKv5Trxcz9cUA1r6huUNSpnERuTWhsrzhRatAiEA7Dzhze87XASWqUQQ0L7HVlt4CgdWP9d7r9eZwfxeWtE="}]},"maintainers":[{"name":"meirionhughes","email":"crakinshot@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/from-emitter-0.1.0.tgz_1506845961078_0.5745483946520835"}},"0.1.1":{"name":"@async-generators/from-emitter","description":"convert an event-emitter to an async-iterable ","version":"0.1.1","author":{"name":"Meirion Hughes","email":"crakinshot@yahoo.com","url":"https://github.com/MeirionHughes"},"keywords":["async","iterator","generator","esnext","typescript","linq","events"],"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/from-emitter.git"},"bugs":{"url":"https://github.com/async-generators/from-emitter/issues"},"devDependencies":{"@async-generators/equal":"^0.2.1","@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node":"^8.0.31","chai":"^4.1.2","chai-as-promised":"^7.1.1","codecov":"^2.3.0","events":"^1.1.1","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":{"@async-generators/subject":"^0.2.1","@async-generators/terminator":"^0.2.0"},"gitHead":"a5bdc366bc937c4d6a9d38adc408cca560f98dde","homepage":"https://github.com/async-generators/from-emitter#readme","_id":"@async-generators/from-emitter@0.1.1","_npmVersion":"5.0.3","_nodeVersion":"8.5.0","_npmUser":{"name":"meirionhughes","email":"crakinshot@yahoo.com"},"dist":{"integrity":"sha512-EYvH2wtNGSiytJYP0SrM1AffHzyvR1mGk4QseKytN/tIBlzu40C/ekWb7v7NSmqc0NoiPB+1FTfCztXf3gZBgA==","shasum":"a0ca504b40d9016161cf5890d9fd61ff12a35553","tarball":"https://registry.npmjs.org/@async-generators/from-emitter/-/from-emitter-0.1.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDQc5XOQTsn5kNT5+pxot8ll+akdFwaElz2zz22pCdwSwIgEFgagDkqTFyK1hSwRDpD9bkTPnL+bCxFT1lYk/beYKU="}]},"maintainers":[{"name":"meirionhughes","email":"crakinshot@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/from-emitter-0.1.1.tgz_1506846320546_0.2275015115737915"}},"0.2.0":{"name":"@async-generators/from-emitter","description":"convert an event-emitter to an async-iterable ","version":"0.2.0","author":{"name":"Meirion Hughes","email":"crakinshot@yahoo.com","url":"https://github.com/MeirionHughes"},"keywords":["async","iterator","generator","esnext","typescript","linq","events"],"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/from-emitter.git"},"bugs":{"url":"https://github.com/async-generators/from-emitter/issues"},"devDependencies":{"@async-generators/equal":"^0.6.1","@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node":"^8.0.31","chai":"^4.1.2","chai-as-promised":"^7.1.1","codecov":"^2.3.0","events":"^1.1.1","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","build:commonjs":"tsc --project tsconfig.build.json --rootDir src/ --outDir ./dist/commonjs","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":{"@async-generators/subject":"^0.3.1","@async-generators/terminator":"^0.3.1"},"gitHead":"dc2873be4524bbc2cc3ca15a0ffdf42216f41fcb","homepage":"https://github.com/async-generators/from-emitter#readme","_id":"@async-generators/from-emitter@0.2.0","_npmVersion":"5.4.2","_nodeVersion":"8.7.0","_npmUser":{"name":"meirionhughes","email":"crakinshot@yahoo.com"},"dist":{"integrity":"sha512-DUjBVXARLQR1YV9xn4xXkpkr2MyG6+rO0FTZdplSQxTVDKTdExiE231WPTU137Xng4rQiica2pFJoNVp+ChIug==","shasum":"446474d10958f2afb2599b9a73a83b3cd9febfb2","tarball":"https://registry.npmjs.org/@async-generators/from-emitter/-/from-emitter-0.2.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC6yTrDQ6W7+Tvuqtgmf6dtqUZCzCXmbicpyeY1UIl4oAiAC+kUp0sh//Rth0jlfdlCvFP0xPX0vqu7M4ZaenqWizA=="}]},"maintainers":[{"name":"meirionhughes","email":"crakinshot@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/from-emitter-0.2.0.tgz_1515774395673_0.34310717647895217"}},"0.3.0":{"name":"@async-generators/from-emitter","description":"convert an event-emitter to an async-iterable ","version":"0.3.0","author":{"name":"Meirion Hughes","email":"crakinshot@yahoo.com","url":"https://github.com/MeirionHughes"},"keywords":["async","iterator","generator","esnext","typescript","linq","events"],"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/from-emitter.git"},"bugs":{"url":"https://github.com/async-generators/from-emitter/issues"},"devDependencies":{"@async-generators/equal":"^0.7","@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node":"^8.0.31","chai":"^4.1.2","chai-as-promised":"^7.1.1","codecov":"^2.3.0","events":"^1.1.1","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":{"@async-generators/subject":"^0.4","@async-generators/terminator":"^0.4"},"gitHead":"17c597c918ddbe9119dee2b54748c2611314ef37","homepage":"https://github.com/async-generators/from-emitter#readme","_id":"@async-generators/from-emitter@0.3.0","_npmVersion":"5.6.0","_nodeVersion":"9.4.0","_npmUser":{"name":"meirionhughes","email":"crakinshot@yahoo.com"},"dist":{"integrity":"sha512-9ne/GfJfbw77wuA08WtuNIvMhpDwAEPT/GX/Dn33y/Bu1zKqO0bOWmcWTpLiHrO2vedEbW0GihfkG7EINEghsA==","shasum":"3496bf2a25f40ddbf2bcf5873ae3ceb3f4aa2dc4","tarball":"https://registry.npmjs.org/@async-generators/from-emitter/-/from-emitter-0.3.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICL0nUGADqvtLKWrVXQjEttnObT/4U/qeiFIoFVZC4j5AiEAn3X8aRpAoouyTrga4gzBoYOMizCmmcwBPthooXxIEuQ="}]},"maintainers":[{"name":"meirionhughes","email":"crakinshot@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/from-emitter-0.3.0.tgz_1516117462837_0.990271347342059"}}},"readme":"# from-emitter\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/from-emitter\n```\n\nThis package's `main` entry points to a `commonjs` dist. \nThe `module` entry points to a `es2015` module dist. Both require native async-generator support, or be down-compiled with a webpack loader. \n\n\n## Exports\n\n### (default) from-emitter(emitter, onNext, onError, onDone [,selectNext][,selectError])\n\n<code>from-emitter()</code> subscribes to `onNext`, `onError` and `onDone` and returns a (one-time) iterable-sequence of captured events. When the event listeners are called, the arguments are passed to `selectNext(...args)` and `selectError(...args)` to pick a value (defaults to the first argument). If the sequence completes (`onDone`), or the consumer terminates early, the event listeners are detached from the emitter and the iterable becomes disposed and cannot be iterated again.  \n\nsource must be a node-js compliment event emitter, with the `addListener ` and `removeListener` methods. \n\n## Example\n\nexample.js\n```js\nconst fromEmitter = require('./dist/commonjs').default;\nconst {EventEmitter} = require('events');\n\nasync function main() {\n  let events = new EventEmitter();\n  let source = fromEmitter(events, \"data\", \"error\", \"close\");\n  let consumer = new Promise(async done => {\n    for await (let item of source) {\n      console.log(item);\n    }\n    console.log(\"...and we're done!\")\n    done();\n  });\n\n  events.emit(\"data\", 1);\n  events.emit(\"data\", 2);\n  events.emit(\"data\", 3);\n  events.emit(\"data\", 4);\n  events.emit(\"close\");\n\n  await consumer;\n}\n\nmain().catch(console.log);\n```\n\nExecute with the latest node.js: \n\n```\nnode example.js // or...\nnode --harmony-async-iteration example.js \n```\n\noutput:\n```\n1\n2\n3\n4\n...and we're done!\n```\n## Typescript\n\nThis library is fully typed and can be imported using: \n\n```ts\nimport fromEmitter from '@async-generators/from-emitter');\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/from-emitter\n[npm-image]: https://img.shields.io/npm/v/@async-generators/from-emitter.svg\n[npm-downloads]: https://img.shields.io/npm/dm/@async-generators/from-emitter.svg\n[travis-url]: https://travis-ci.org/async-generators/from-emitter\n[travis-image]: https://img.shields.io/travis/async-generators/from-emitter/master.svg\n[codecov-url]: https://codecov.io/gh/async-generators/from-emitter\n[codecov-image]: https://codecov.io/gh/async-generators/from-emitter/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:21.274Z","created":"2017-10-01T08:19:21.938Z","0.1.0":"2017-10-01T08:19:21.938Z","0.1.1":"2017-10-01T08:25:21.515Z","0.2.0":"2018-01-12T16:26:35.735Z","0.3.0":"2018-01-16T15:44:23.414Z"},"homepage":"https://github.com/async-generators/from-emitter#readme","keywords":["async","iterator","generator","esnext","typescript","linq","events"],"repository":{"type":"git","url":"git+https://github.com/async-generators/from-emitter.git"},"author":{"name":"Meirion Hughes","email":"crakinshot@yahoo.com","url":"https://github.com/MeirionHughes"},"bugs":{"url":"https://github.com/async-generators/from-emitter/issues"},"license":"MIT","readmeFilename":"README.md"}