{"name":"consumable-stream","version":"1.0.0","description":"A readable async stream which can be iterated over using a for-await-of loop.","main":"index.js","scripts":{"test":"./node_modules/mocha/bin/_mocha --reporter spec --timeout 10000 --slow 10000"},"repository":{"type":"git","url":"git+ssh://git@github.com/SocketCluster/consumable-stream.git"},"keywords":["async","generator","stream","data","for-await-of"],"author":{"name":"Jonathan Gros-Dubois"},"license":"MIT","bugs":{"url":"https://github.com/SocketCluster/consumable-stream/issues"},"homepage":"https://github.com/SocketCluster/consumable-stream#readme","devDependencies":{"mocha":"^5.2.0"},"gitHead":"9ba8e2490e544d7bb2a3afcfe6c81656f1f9ecd8","_id":"consumable-stream@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"10.0.0","_npmUser":{"name":"topcloudsystems","email":"grosjona@yahoo.com.au"},"dist":{"integrity":"sha512-CwX4ZzpSMWxTG9Q3tNM+UNlevMfWX1hjR033MlKkT8ChfH9R+Rl7YQu7FCeMMv4bRv9yO33p8aYoX0EwdijaUA==","shasum":"5b0862414730834541792532ee4cf98e22a946f6","tarball":"http://registry-npm.ywwl.com/consumable-stream/download/consumable-stream-1.0.0.tgz","fileCount":5,"unpackedSize":7351,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcadwECRA9TVsSAnZWagAAOjMQAINp6ca3tlUBViDLwMGz\nU0+CBUIxEbhk0uEE0KpbMqwGgl5luz0dSIqbjHxD6UMJTyDJwyD1wiNa9qlC\nmsH0Qp04A9NFcg5KNPVAgiqKFMJ2f9H5ax/m3u9LDCYVKJaXX4CFArGs2y/n\ncmHyhjClT+r6kcR8Gpz2foBrj/mz/vX/9t5lbkccb7m54IZ2SgLvw5cMOJxw\n4OvVEsvNo+Fn+Fw3K47ycijSHtLgLMqO2z5D/ougg3FWPtD57nFJ0MrNLe78\nduIYUOd1iR8iUeVxYXQ8K3YTamMD4LbMhmS5mu6raSUDf2iacdBz2sHWIyLV\nYdOHnckREVWnCeR2X9g9UH3wrOrBdtp7/orMu7CEGFlXJSi2o1RDMOrq3vXs\ncNGNS1Bm442qWWRm3YlnPdutkUgo6VobUQCNuR61r/R2S0Ha/zFSzAXfBBBr\nDrtoK2AbDFOrhlkj0t8i/YFeh7R3LdkdlE3J3w1NwTyi/onZCE7Zi8DAlKnY\nX9RpurDWuUiYdxV5e+yzcsx0x6HzbuISRau/GUMqmqcGzqln+ZfzlW4yqVhx\ntPLRlpIsIZtdl7WcslNBpc2D2uhkx253kokk/W3CpDuANWEL8y1tx+6gfiCx\nLuZ2zh26NuhqTZECDZTATZ/ZLwAsJ0itWORmgNRBnXiof95TYCGCwrrmyL4+\njFBF\r\n=fvlS\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDTAWR/FFfmqzUOIsvuBVltvBOMvs7QkTJE5pqNc650KgIgeP4xWIVp50D274iilpsF7AYfaVopmOn5fQDSYcOT74o="}],"size":2866,"noattachment":false,"key":"/consumable-stream/-/consumable-stream-1.0.0.tgz"},"maintainers":[{"name":"topcloudsystems","email":"grosjona@yahoo.com.au"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/consumable-stream_1.0.0_1550441476000_0.7802629754775294"},"_hasShrinkwrap":false,"readme":"# consumable-stream\nA readable stream which can be iterated over using a for-await-of loop or using a while loop with await inside.\n\nThe `ConsumableStream` constructor is an abstract class which must be subclassed. Its `next()` and `createConsumer()` methods must be overriden.\n\nFor a concrete subclass of `ConsumableStream`, see `WritableConsumableStream`: https://github.com/SocketCluster/writable-consumable-stream\n\n## Installation\n\n```\nnpm install consumable-stream\n```\n\n## Usage\n\nThe `ConsumableStream` class exposes the following methods:\n\n- `[Symbol.asyncIterator]`: Makes the instance iterable using a for-await-of loop.\n- `next`: Returns a `Promise` which will resolve an object in the form `{value: data, done: boolean}` whenever some data is received or when the stream ends.\n- `once`: Similar to `next()` except that the resolved value will be the raw data and it will not resolve when the stream ends. Note that once `once()` is called, it cannot be cancelled; the affected closure will stay in memory until either `once()` resolves or until the stream is ended or garbage collected.\n\n```js\n// Consume data objects from consumableStream as they are written to the stream.\n(async () => {\n  for await (let data of consumableStream) {\n    console.log(data);\n  }\n})();\n\n// Consume only the next data object which is written to the stream.\n(async () => {\n  let data = await consumableStream.once();\n  console.log(data);\n})();\n```\n","publish_time":1550441476168,"_cnpm_publish_time":1550441476168,"dist-tags":{"latest":"3.0.0"}}