Skip to content
Myr

`original` will now throw when invoked on a non-draft

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

authored by Michel Weststrate · committed by Michel Weststrate · parent 870f44e · Browse files · 3 files+18 added−10 removed
This commit

State

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

Diff stats

3 files+18 added−10 removed

  • tests:+13 added−5 removed
  • other:+5 added−5 removed

3 files+18 added−10 removed

modified:__tests__/original.js+13 added-5 removed
modified:src/utils/common.ts+2 added-5 removed
45 unmodified lines
46/** Get the underlying object that is represented by the given draft */47/*#__PURE__*/48export function original<T>(value: T): T | undefined49export function original(value: Drafted<any>): any {50 if (value && value[DRAFT_STATE]) {51 return value[DRAFT_STATE].base_ as any52 }53 // otherwise return undefined54 // TODO: or die50 if (!isDraft(value)) die(23, value)51 return value[DRAFT_STATE].base_52}5354/*#__PURE__*/55export const ownKeys: (target: AnyObject) => PropertyKey[] =
132 unmodified lines
modified:src/utils/errors.ts+3 added