Created
February 21, 2017 15:29
-
-
Save foxfirecodes/1f7f13180bcd93d606417bda23a814db to your computer and use it in GitHub Desktop.
Just a demo of the oddity with LevelUP's createValueStream() method
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
const level = require('level'); | |
const db = level('./testDB', { valueEncoding: 'json' }); | |
async function main() { | |
await db.put('key-1', 'some value'); | |
await db.put('key-2', ''); | |
await db.put('key-3', -1); | |
await db.put('key-4', 0); | |
await db.put('key-5', 1); | |
await db.put('key-6', true); | |
await db.put('key-7', false); | |
await db.put('key-8', {}); | |
await db.put('key-9', { | |
foo: 'bar', | |
sub: { | |
number: 5 | |
} | |
}); | |
await db.put('key-10', null); | |
db.createValueStream() | |
.on('data', value => { | |
console.log(value); | |
}); | |
// => Output: | |
// false | |
// true | |
// some value | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment