diff --git a/mod.ts b/mod.ts index 778c480..5ac69d9 100644 --- a/mod.ts +++ b/mod.ts @@ -103,7 +103,7 @@ export class Store implements Subject { * @remarks * To mutate the state, use {@link Store.set}. */ - public get state(): T { return structuredClone(this.#state) as T; } + public get state(): T { return this.#state; } /** * Convenience method to create a unique pointer. @@ -169,9 +169,9 @@ export class Store implements Subject { */ public set(options: T | ((prevState: T) => T)): void { if (typeof options === "function") { - this.#state = structuredClone((options as (prevState: T) => T)(structuredClone(this.state) as T)) as T; + this.#state = (options as (prevState: T) => T)(this.#state); } else { - this.#state = structuredClone(options) as T; + this.#state = options; } this.notify();