Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
node_modules/ | 12-May-2024 | - | 3,249 | 2,177 | ||
.npmignore | D | 12-May-2024 | 13 | 2 | 1 | |
.travis.yml | D | 12-May-2024 | 60 | 6 | 5 | |
LICENSE | D | 12-May-2024 | 1.1 KiB | 22 | 17 | |
README.md | D | 12-May-2024 | 834 | 40 | 26 | |
index.js | D | 12-May-2024 | 1.3 KiB | 71 | 57 | |
package.json | D | 12-May-2024 | 1.5 KiB | 57 | 56 | |
test.js | D | 12-May-2024 | 1.2 KiB | 61 | 49 |
README.md
1 # stream-iterate 2 3 Iterate through the values in a stream. 4 5 ``` 6 npm install stream-iterate 7 ``` 8 9 [](http://travis-ci.org/mafintosh/stream-iterate) 10 11 ## Usage 12 13 ``` js 14 var iterate = require('stream-iterate') 15 var from = require('from2') 16 17 var stream = from.obj(['a', 'b', 'c']) 18 19 var read = iterate(stream) 20 21 loop() 22 23 // recursively iterates through each item in the stream 24 function loop () { 25 read(function (err, data, next) { 26 console.log(err, data) 27 next() 28 loop() 29 }) 30 } 31 ``` 32 33 If you don't call `next` and call `read` again the same `(err, value)` pair will be returned. 34 35 You can use this module to implement stuff like [a streaming merge sort](https://github.com/mafintosh/stream-iterate/blob/master/test.js#L5-L47). 36 37 ## License 38 39 [MIT](LICENSE) 40