Skip to content

Commit

Permalink
Merge pull request #12 from HugeLetters/main
Browse files Browse the repository at this point in the history
[Bug] Cannot use 'in' operator to search for 'subscribe' in value
  • Loading branch information
ottomated authored Nov 4, 2023
2 parents 960fbf9 + c3717f2 commit 63fef09
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/utils/isSvelteStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ import { Readable } from 'svelte/store';
export function isSvelteStore<TStore extends object>(
obj: StoreOrVal<TStore>,
): obj is Readable<TStore> {
return 'subscribe' in obj && typeof obj.subscribe === 'function';
return (
typeof obj === 'object' &&
'subscribe' in obj &&
typeof obj.subscribe === 'function'
);
}

0 comments on commit 63fef09

Please sign in to comment.