Promisifying Level, issue with encodeLtgt?
See original GitHub issueHey guys,
Not sure if this really is the proper place to ask, but I’ll try anyway (unless you guys have a Discord or Slack server).
I’m attempting to promisify level
in my own way - the existing then-level
isn’t actually working, a few issues pushed me to work on my own version, which also happens to support node 8 native promisifying using the util
module.
The full code is gisted here. The issue I have specifically is when attempting to create a createKeyStream
.
Code:
const lp = new LevelPromise('hallo');
const test = async() => {
await lp.put('hallo', 'hehe');
const rv = await lp.get('hallo');
console.log(rv);
const output = [];
lp.createKeyStream()
.on("data", key => lp.get(key).then(d => output.push(JSON.parse(d))))
.on("end", () => console.log(output));
//await lp.close();
//lp.destroy();
}
test();
Resulting Error:
Uncaught Promise Error: TypeError: Cannot read property 'encodeLtgt' of undefined
at LevelPromise.LevelUP.readStream.LevelUP.createReadStream (/root/level-promise/node_modules/levelup/lib/levelup.js:323:24)
at LevelPromise.LevelUP.keyStream.LevelUP.createKeyStream (/root/level-promise/node_modules/levelup/lib/levelup.js:336:15)
at test (/root/level-promise/index.js:61:6)
at <anonymous>
I’m not having this issue without the promisify stuff, createKeyStream works correctly.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Promisification - The Modern JavaScript Tutorial
“Promisification” is a long word for a simple transformation. It's the conversion of a function that accepts a callback into a function that ......
Read more >Promisify of method without last argument callback ... - GitHub
Currently, our documentation states: promisify() assumes that original is a function taking a callback as its final argument in all cases, ...
Read more >How To Turn SetTimeout and SetInterval Into Promises
How to promisify setTimeout. Take this code: const foo = () => { setTimeout(() => { console.log('Callback based stuff ...
Read more >How to Write Your Own Promisify Function from Scratch
Introduction In this article, you will learn how to write your own promisify function from scratch. Promisification helps in dealing with ...
Read more >Promisifying Your Node Callback Functions: Grouparoo Blog
The Grouparoo application is written in JavaScript (Node). It uses the modern promise-based pattern ( async / await ) for reading and ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Now you’re binding 😉 This should be the same as doing
Credit goes to @ralphtheninja 💘
@eslachance The reason that
this[key] = prototype[key]
doesn’t work is because in JavaScript the value ofthis
is determined by how a function is called.