Skip to content

Latest commit

 

History

History
42 lines (26 loc) · 702 Bytes

original.md

File metadata and controls

42 lines (26 loc) · 702 Bytes

mutativeDocs


mutative / original

Function: original()

original<T>(target): T

original(draft) to get original state in the draft mutation function.

Example

import { create, original } from '../index';

const baseState = { foo: { bar: 'str' }, arr: [] };
const state = create(
  baseState,
  (draft) => {
    draft.foo.bar = 'str2';
    expect(original(draft.foo)).toEqual({ bar: 'str' });
  }
);

Type Parameters

T

Parameters

target: T

Returns

T

Defined in

original.ts:21