Skip to content

Commit

Permalink
Fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Dec 18, 2023
1 parent e9f665d commit 49810b1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 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.4",
"version": "0.8.5",
"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
2 changes: 1 addition & 1 deletion packages/stores/src/pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function pipeStep<T, U>(
.reverse()
);

if ((v as Readable<any>).subscribe) {
if (!!v && (v as Readable<any>).subscribe) {
return (v as Readable<any>).subscribe((value) => {
if ((value as AsyncStatus<U>).status) {
set(value);
Expand Down
17 changes: 17 additions & 0 deletions packages/stores/tests/pipe.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ it("pipe with normal fn", async () => {
});
});

it("pipe with normal fn that returns undefined", async () => {
const asyncReadableStore = asyncReadable(async (set) => {
await sleep(10);
set("hi");
});
const pipeStore = pipe(asyncReadableStore, (s) => undefined);
const subscriber = pipeStore.subscribe(() => {});

expect(get(pipeStore)).to.deep.equal({ status: "pending" });
await sleep(20);

expect(get(pipeStore)).to.deep.equal({
status: "complete",
value: undefined,
});
});

it("pipe with promise", async () => {
const asyncReadableStore = asyncReadable(async (set) => {
await sleep(10);
Expand Down

0 comments on commit 49810b1

Please sign in to comment.