I have a function that does something asynchronously, e.g.,
const doSomething = () => {
request(url)
.pipe(hasher)
.on('finish', () => {
// "return" only here
return hasher.read();
});
});
I would now like to "wait" in the function until hasher.read()
can be returned instead of returning early with undefined
(which is what the above variant does).
Ideally, I'd use doSomething
as
const out = yield doSomething();
Any hints?