-
-
Save Raynos/4582216 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var WriteStream = require("write-stream") | |
| var toArray = require("write-stream/array") | |
| /************************************** A *************************************/ | |
| db.readStream().pipe(WriteStream(function write(data) { | |
| assert.equal(data, { | |
| value: 'value', | |
| key: 'key' | |
| }) | |
| }, function end() { | |
| // fini | |
| })).on("error", function (err) { | |
| // error? | |
| }) | |
| db.readStream().pipe(toArray(function finish(data) { | |
| assert.equal(data, [{ | |
| value: 'value', | |
| key: 'key' | |
| }, { | |
| value: 'value2', | |
| key: 'key2' | |
| }]) | |
| })).on("error", function (err) { | |
| // error? | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the tip. I'm still not very confortable with streams and I wasn't aware of the
write-streammodule.How about the error handling? with cursor, when a error occurs, it is passed to the end function