UNPKG

mutative

Version:

A JavaScript library for efficient immutable updates

30 lines (29 loc) 870 B
import { type Draft, type ProxyDraft } from './interface'; export declare function handleReturnValue<T extends object>(options: { rootDraft: ProxyDraft<any> | undefined; value: T; useRawReturn?: boolean; isContainDraft?: boolean; isRoot?: boolean; }): void; /** * `current(draft)` to get current state in the draft mutation function. * * ## Example * * ```ts * import { create, current } from '../index'; * * const baseState = { foo: { bar: 'str' }, arr: [] }; * const state = create( * baseState, * (draft) => { * draft.foo.bar = 'str2'; * expect(current(draft.foo)).toEqual({ bar: 'str2' }); * }, * ); * ``` */ export declare function current<T extends object>(target: Draft<T>): T; /** @deprecated You should call current only on `Draft<T>` types. */ export declare function current<T extends object>(target: T): T;