Closed jwerle closed 4 years ago
Hey @jwerle, how are you?
Can you show me the use case where is not working, I try the test and is passing and doing something like below also works:
const hypercore = require('hypercore')
const ram = require('random-access-memory')
const feed = hypercore(ram)
feed.append('foo', () => {
feed.append('bar', () => {
const stream = feed.createReadStream({ batch: 100 })
stream.on('data', (data) => {
console.log(data)
})
})
})
Just to know what is the case where the arrow function is not respecting the lexical scoping and maybe add it to the test too.
Hey @tinchoz49 !
I didn't mention it, because I didn't realize it, but this was running inside of a worker launched by piscina
Ah ok, I don't how piscina it's losing the bound in that case (maybe a transpiler issue?) haha but anyway I prefer the fix on your PR than playing with arrows and this
.
Thanks!
yeah I didn't dig into it but no problem! :palm_tree:
Sounds like a transpiler problem to me. Down to merge the fix tho if that helps you
@mafintosh thank you!
If you set
opts.batch
to something greater than1
, this error is triggered. The cause is an unboundthis
: https://github.com/hypercore-protocol/hypercore/blob/master/index.js#L1361A possible fix: