{"name":"consumable-stream","version":"3.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":"1c0efdb43b5bb8bc4ccbdce54d0b749850f04bd1","_id":"consumable-stream@3.0.0","_nodeVersion":"16.16.0","_npmVersion":"8.17.0","dist":{"integrity":"sha512-CnnsJ9OG9ouxAjt3pc63/DaerezRo/WudqU71pc5epaIUi7NHu2T4v+3f0nKbbCY7icS/TfQ1Satr9rwZ7Jwsg==","shasum":"2bf140e0c5f9b63d6fa116ac6b05e53713d3cb41","tarball":"http://registry-npm.ywwl.com/consumable-stream/download/consumable-stream-3.0.0.tgz","fileCount":5,"unpackedSize":7470,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID2r+XAlXU2sEx7uTiKxfYWY1LLIkur1U2aO7bUIJgC0AiEA6j949YOMFl+j2UWWOj7Zri8Z6fJe6W/Zt/QgRChgDcM="}],"size":2915,"noattachment":false,"key":"/consumable-stream/-/consumable-stream-3.0.0.tgz"},"_npmUser":{"name":"topcloudsystems","email":"grosjona@yahoo.com.au"},"directories":{},"maintainers":[{"name":"topcloudsystems","email":"grosjona@yahoo.com.au"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/consumable-stream_3.0.0_1694029807597_0.4709778061171592"},"_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":1694029807761,"_cnpm_publish_time":1694029807761,"dist-tags":{"latest":"3.0.0"}}