import { batch } from "@preact-signals/unified-signals"; import type { Except, ReadonlyKeysOf } from "type-fest"; import { FlatStore } from "./createFlatStore"; type AnyRecord = Record; export type FlatStoreSetterFromStore> = FlatStoreSetter ? TRes : never>; export type FlatStoreSetter = ( newValue: Partial>> ) => void; export const setterOfFlatStore = (store: FlatStore): FlatStoreSetter => (newValue) => { batch(() => { for (const key in newValue) { // @ts-expect-error store[key] = newValue[key]; } }); };