mafintosh / hyperdb

Distributed scalable database
MIT License
752 stars 75 forks source link

Async reduce #80

Open mafintosh opened 6 years ago

mafintosh commented 6 years ago

Would be neat if the reduce option had an async cousin, reduceAsync(a, b, cb). Then a program could prompt a user on reduce

philcockfield commented 5 years ago

That would be awesome.

philcockfield commented 5 years ago

I can't seem to get a reduce function I pass into the hyperdb constructor to invoke.

https://github.com/mafintosh/hyperdb/blob/8e9d99b46bd01d5616bfc2778392c3c0bb6fecab/lib/get.js#L96

Shouldn't like 96 pass an initial empty array to the list reducer?, eg:

if (reduce) return results.length ? results.reduce(reduce, []) : null

If I do that, the passed in function does run.

I can put together a PR for this, but wanted to sanity check that I wasn't missing something simple/stupid.