UNPKG

mutative

Version:

A JavaScript library for efficient immutable updates

28 lines (25 loc) 597 B
import { makeCreator } from './makeCreator'; /** * `create(baseState, callback, options)` to create the next state * * ## Example * * ```ts * import { create } from '../index'; * * const baseState = { foo: { bar: 'str' }, arr: [] }; * const state = create( * baseState, * (draft) => { * draft.foo.bar = 'str2'; * }, * ); * * expect(state).toEqual({ foo: { bar: 'str2' }, arr: [] }); * expect(state).not.toBe(baseState); * expect(state.foo).not.toBe(baseState.foo); * expect(state.arr).toBe(baseState.arr); * ``` */ const create = makeCreator(); export { create };