Skip to content
Myr

types: createDraft/finishDraft functions

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Michel Weststrate · committed by aleclarson · parent e2eb0a8 · Browse files · 2 files+26 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+26 added−0 removed

  • other:+26 added−0 removed

2 files+26 added−0 removed

modified:src/immer.d.ts+13 added
152 unmodified lines
153 * This function is a producer, which means copy-on-write is in effect.154 */155export function applyPatches<S>(base: S, patches: Patch[]): S156157/**158 * Creates a mutable draft from an (immutable) object / array.159 * The draft can be modified until `finishDraft` is called160 */161export function createDraft<T>(base: T): Draft<T>162163/**164 * Given a draft that was created using `createDraft`,165 * finalizes the draft into a new immutable object.166 * Optionally a patch-listener can be provided to gather the patches that are needed to construct the object.167 */168export function finishDraft<T>(base: Draft<T>, listener?: PatchListener): T169170/** Get the underlying object that is represented by the given draft */171export function original<T>(value: T): T | void172173/** Returns true if the given value is an Immer draft */
66 unmodified lines
modified:src/immer.js.flow+13 added
88 unmodified lines
8990declare export function original<S>(value: S): ?S9192declare export function isDraft(value: any): boolean9394/**95 * Creates a mutable draft from an (immutable) object / array. 96 * The draft can be modified until `finishDraft` is called97 */98declare export function createDraft<T>(base: T): T99100/**101 * Given a draft that was created using `createDraft`, 102 * finalizes the draft into a new immutable object.103 * Optionally a patch-listener can be provided to gather the patches that are needed to construct the object.104 */105declare export function finishDraft<T>(base: T, listener?: PatchListener): T