Skip to content
Myr

Killed `die`, -14 bytes

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 bfa7ddd · Browse files · 3 files+3 added−15 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+3 added−15 removed

  • other:+3 added−15 removed

3 files+3 added−15 removed

modified:src/plugins/patches.ts+2 added-7 removed
10 unmodified lines
11 PatchPath,12 get,13 each,14 has,15 die,15 getArchtype,16 ProxyType,17 Archtype,18 isSet,
37 unmodified lines
56 basePath: PatchPath,57 patches: Patch[],58 inversePatches: Patch[]59 ) {61 let {base_, assigned_, copy_} = state62 /* istanbul ignore next */63 if (!copy_) die()60 const {base_, assigned_} = state61 const copy_ = state.copy_!6263 // Reduce complexity by ensuring `base` is never longer.64 if (copy_.length < base_.length) {65 // @ts-ignore
121 unmodified lines
187 function applyPatches<T>(draft: T, patches: Patch[]): T {188 patches.forEach(patch => {189 const {path, op} = patch190193 /* istanbul ignore next */194 if (!path.length) die()195191 let base: any = draft192 for (let i = 0; i < path.length - 1; i++) {193 base = get(base, path[i])194 invariant(typeof base === "object","Cannot apply patch, path doesn't resolve: " + path.join("/")) // prettier-ignore
69 unmodified lines
modified:src/common.ts-6 removed
82 unmodified lines
8384/*#__PURE__*/85export function getArchtype(thing: any): Archtype {86 /* istanbul ignore next */87 if (!thing) die()87 if (thing[DRAFT_STATE]) {88 switch ((thing as Drafted)[DRAFT_STATE].type) {89 case ProxyType.ES5Object:90 case ProxyType.ProxyObject:
126 unmodified lines
217 writable: true218 })219}220222/* istanbul ignore next */223export function die(): never {224 invariant(false, "Illegal state, please file a bug")225}226221export function assertUnrevoked(state: any /*ES5State | MapState | SetState*/) {222 invariant(223 !state.revoked_,224 "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " +
3 unmodified lines
modified:src/immerClass.ts+1 added-2 removed
10 unmodified lines
11 ImmerScope,12 processResult,13 NOTHING,14 maybeFreeze,15 die,15 Patch,16 Objectish,17 DRAFT_STATE,18 Draft,
146 unmodified lines
165 this.produceWithPatches(state, (draft: any) => arg1(draft, ...args))166 }167 // non-curried form168 /* istanbul ignore next */170 if (arg3) die()169 invariant(!arg3)170 let patches: Patch[], inversePatches: Patch[]171 const nextState = this.produce(arg1, arg2, (p: Patch[], ip: Patch[]) => {172 patches = p173 inversePatches = ip
102 unmodified lines