{"_id":"consumable-stream","_rev":"3147540","name":"consumable-stream","description":"A readable async stream which can be iterated over using a for-await-of loop.","dist-tags":{"latest":"3.0.0"},"maintainers":[{"name":"topcloudsystems","email":"grosjona@yahoo.com.au"}],"time":{"modified":"2023-11-27T07:20:33.000Z","created":"2019-02-17T22:11:16.168Z","3.0.0":"2023-09-06T19:50:07.761Z","2.0.0":"2020-02-07T17:52:57.142Z","1.0.0":"2019-02-17T22:11:16.168Z"},"users":{},"author":{"name":"Jonathan Gros-Dubois"},"repository":{"type":"git","url":"git+ssh://git@github.com/SocketCluster/consumable-stream.git"},"versions":{"3.0.0":{"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":{"shasum":"2bf140e0c5f9b63d6fa116ac6b05e53713d3cb41","size":2915,"noattachment":false,"key":"/consumable-stream/-/consumable-stream-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/consumable-stream/download/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,"_cnpmcore_publish_time":"2023-09-06T19:50:07.761Z","publish_time":1694029807761,"_source_registry_name":"default","_cnpm_publish_time":1694029807761},"2.0.0":{"name":"consumable-stream","version":"2.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":"fac77e46e2544bbecd129355faad0b9b8d6a9de4","_id":"consumable-stream@2.0.0","_nodeVersion":"11.13.0","_npmVersion":"6.7.0","dist":{"shasum":"11d3c7281b747eb9efd31c199b3a8b1711bec654","size":2811,"noattachment":false,"key":"/consumable-stream/-/consumable-stream-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/consumable-stream/download/consumable-stream-2.0.0.tgz"},"maintainers":[{"name":"topcloudsystems","email":"grosjona@yahoo.com.au"}],"_npmUser":{"name":"topcloudsystems","email":"grosjona@yahoo.com.au"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/consumable-stream_2.0.0_1581097976983_0.09921821712980261"},"_hasShrinkwrap":false,"publish_time":1581097977142,"_cnpm_publish_time":1581097977142},"1.0.0":{"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":{"shasum":"5b0862414730834541792532ee4cf98e22a946f6","size":2866,"noattachment":false,"key":"/consumable-stream/-/consumable-stream-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/consumable-stream/download/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,"publish_time":1550441476168,"_cnpm_publish_time":1550441476168}},"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","_attachments":{},"homepage":"https://github.com/SocketCluster/consumable-stream#readme","bugs":{"url":"https://github.com/SocketCluster/consumable-stream/issues"},"license":"MIT"}