-
-
Save sergioramos/4578979 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 cursor = require('levelup-cursor') | |
| /************************************** A *************************************/ | |
| db.readStream().pipe(cursor.each(function (data) { | |
| assert.equal(data, { | |
| value: 'value', | |
| key: 'key' | |
| }) | |
| }, function (e) { | |
| assert.equal(e, null) | |
| })) | |
| db.readStream().pipe(cursor.all(function (e, data) { | |
| assert.equal(e, null) | |
| assert.equal(data, [{ | |
| value: 'value', | |
| key: 'key' | |
| }, { | |
| value: 'value2', | |
| key: 'key2' | |
| }]) | |
| })) | |
| /************************************** B *************************************/ | |
| db.readStream().pipe(cursor.each(function (data) { | |
| assert.equal(data, { | |
| value: 'value', | |
| key: 'key' | |
| }) | |
| }, function (e) { | |
| assert.equal(e, null) | |
| })) | |
| db.readStream().pipe(cursor.all(function (e, data) { | |
| assert.equal(e, null) | |
| assert.equal(data, { | |
| 'key': 'value', | |
| 'key2': 'value2' | |
| }) | |
| })) | |
| /************************************** C *************************************/ | |
| db.readStream().pipe(cursor.each(function (data) { | |
| assert.equal(data, { | |
| 'key': 'value' | |
| }) | |
| }, function (e) { | |
| assert.equal(e, null) | |
| })) | |
| db.readStream().pipe(cursor.all(function (e, data) { | |
| assert.equal(e, null) | |
| assert.equal(data, { | |
| 'key': 'value', | |
| 'key2': 'value2' | |
| }) | |
| })) |
Author
@rvagg thanks for the response.
While using the API I found the explicitness useful sometimes, and too verbose other times. It depends on what I need :/ Thats why I'm in doubt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I personally prefer the explicitness of A but some of the feedback I've got from the
batch()API is the it's too verbose for some people.