Skip to content

Commit

Permalink
JoinOptions added to sliceAndJoin
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Jan 3, 2024
1 parent 0a3add8 commit e5e4937
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/stores/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@holochain-open-dev/stores",
"version": "0.8.9",
"version": "0.8.10",
"description": "Re-export of svelte/store, with additional utilities to build reusable holochain-open-dev modules",
"author": "[email protected]",
"main": "dist/index.js",
Expand Down
6 changes: 4 additions & 2 deletions packages/stores/src/slice-and-join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ import { GetonlyMap, HoloHashMap, slice } from "@holochain-open-dev/utils";
import { HoloHash } from "@holochain/client";
import { joinAsyncMap } from "./join-map.js";
import { AsyncReadable } from "./async-readable.js";
import { JoinAsyncOptions } from "./async-derived.js";

export type Option<T> = T | undefined;

// Takes a map of AsyncReadables, it gets the stores for the given hashes,
// and returns those stores joined
export function sliceAndJoin<H extends HoloHash, T>(
map: GetonlyMap<H, AsyncReadable<Option<T>>>,
hashes: Array<H>
hashes: Array<H>,
joinOptions?: JoinAsyncOptions
): AsyncReadable<ReadonlyMap<H, T>> {
const s = slice(map, hashes);

const hs = new HoloHashMap(
Array.from(s.entries()).filter(([h, v]) => v !== undefined)
) as HoloHashMap<H, AsyncReadable<T>>;

return joinAsyncMap(hs);
return joinAsyncMap(hs, joinOptions);
}

0 comments on commit e5e4937

Please sign in to comment.