Closed aboodman closed 3 years ago
Here you go!
async function toArray(it) {
const res = [];
for await (const v of it) {
res.push(v);
}
return res;
}
It would be nice to have it built-in 😀
On Wed, Mar 3, 2021 at 1:02 PM Erik Arvidsson notifications@github.com wrote:
Here you go!
async function toArray(it) { const res = []; for await (const v of it) { res.push(v); } return res;}
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rocicorp/replicache-sdk-js/issues/292#issuecomment-790134717, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAATUBD3R7PK3ILBKNRLR4TTB25YTANCNFSM4YSBFODQ .
Another option would be to add array version to ScanIterator
:
const keys = await rep.scan().keysArray();
const values = await rep.scan().valuesArray();
const entries = await rep.scan().entriesArray();
or even...
const keys = await rep.scan().keys().toArray();
const values = await rep.scan().values().toArray();
const entries = await rep.scan().entries().toArray();
I feel bad pulling out all the values when I'm not using them, but I also don't want to manually iterate the keys asynchronously.