Skip to content

Instantly share code, notes, and snippets.

@foxfirecodes
Created February 21, 2017 15:29
Show Gist options
  • Save foxfirecodes/1f7f13180bcd93d606417bda23a814db to your computer and use it in GitHub Desktop.
Save foxfirecodes/1f7f13180bcd93d606417bda23a814db to your computer and use it in GitHub Desktop.
Just a demo of the oddity with LevelUP's createValueStream() method
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