Skip to content
Myr

common.ts

This file

Path

src/utils/common.ts

286 lines · 7.7 KiB · TypeScript

Last changed by

feat: Override array methods to avoid proxy creation while iterating and updating (#1184)Mark Eriksonbefore adoptiond38a9d0

History of this file

Take it

The walk stopped after 200 commits: lines older than 6555173 point at it.

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 1–9why, one step back
1import {
2 DRAFT_STATE,3 DRAFTABLE,4 Objectish,5 Drafted,6 AnyObject,7 AnyMap,8 AnySet,9 ImmerState,

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 10why, one step back
10 ArchType,

feat(performance): Make non-strict mode faster for classes. Addresses #1071Michel Weststratebefore adoption53e3203

lines 11–12why, one step back
11 die,
12 StrictMode

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 13–14why, one step back
13} from "../internal"
14

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 15why, one step back
15const O = Object

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 16why, one step back
16

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 17–26why, one step back
17export const getPrototypeOf = O.getPrototypeOf
1819export const CONSTRUCTOR = "constructor"20export const PROTOTYPE = "prototype"2122export const CONFIGURABLE = "configurable"23export const ENUMERABLE = "enumerable"24export const WRITABLE = "writable"25export const VALUE = "value"26

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 27–28why, one step back
27/** Returns true if the given value is an Immer draft */
28/*#__PURE__*/

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 29why, one step back
29export let isDraft = (value: any): boolean => !!value && !!value[DRAFT_STATE]

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 30–36why, one step back
30
31/** Returns true if the given value can be drafted by Immer */32/*#__PURE__*/33export function isDraftable(value: any): boolean {34 if (!value) return false35 return (36 isPlainObject(value) ||

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 37why, one step back
37 isArray(value) ||

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 38why, one step back
38 !!value[DRAFTABLE] ||

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 39why, one step back
39 !!value[CONSTRUCTOR]?.[DRAFTABLE] ||

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 40–44why, one step back
40 isMap(value) ||
41 isSet(value)42 )43}44

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 45why, one step back
45const objectCtorString = O[PROTOTYPE][CONSTRUCTOR].toString()

feat: Optimize Immer performance where possible, introduce `setUseStrictIteration` (#1164)Mark Eriksonbefore adoptione1996ce

line 46why, one step back
46const cachedCtorStrings = new WeakMap()

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 47–48why, one step back
47/*#__PURE__*/
48export function isPlainObject(value: any): boolean {

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 49–51why, one step back
49 if (!value || !isObjectish(value)) return false
50 const proto = getPrototypeOf(value)51 if (proto === null || proto === O[PROTOTYPE]) return true

feat: Optimize Immer performance where possible, introduce `setUseStrictIteration` (#1164)Mark Eriksonbefore adoptione1996ce

line 52why, one step back
52

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 53why, one step back
53 const Ctor = O.hasOwnProperty.call(proto, CONSTRUCTOR) && proto[CONSTRUCTOR]

chore: reduce size by using TS const enum (#812)houfengbefore adoptionb1fac9d

line 54why, one step back
54 if (Ctor === Object) return true

fix: isPlainObject: add quick comparison between input and `Object` to short-circuit taxing `Function.toString` invocations (#805)Ben Elliottbefore adoption07575f3

line 55why, one step back
55

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 56why, one step back
56 if (!isFunction(Ctor)) return false

feat: Optimize Immer performance where possible, introduce `setUseStrictIteration` (#1164)Mark Eriksonbefore adoptione1996ce

lines 57–64why, one step back
57
58 let ctorString = cachedCtorStrings.get(Ctor)59 if (ctorString === undefined) {60 ctorString = Function.toString.call(Ctor)61 cachedCtorStrings.set(Ctor, ctorString)62 }6364 return ctorString === objectCtorString

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 65–70why, one step back
65}
6667/** Get the underlying object that is represented by the given draft */68/*#__PURE__*/69export function original<T>(value: T): T | undefined70export function original(value: Drafted<any>): any {

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 71why, one step back
71 if (!isDraft(value)) die(15, value)

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 72–74why, one step back
72 return value[DRAFT_STATE].base_
73}74

fix: Fix handling of Symbol and non-enumerable properties in finalization / freeze. Fixes #1096, #1087, #1091 (#1105))Michel Weststratebefore adoption8949a3e

lines 75–76why, one step back
75/**
76 * Each iterates a map, set or array.

chore: Fix typo in comment in common.ts (#1113)Fredrik Vaeng Røtnesbefore adoption073d634

line 77why, one step back
77 * Or, if any other kind of object, all of its own properties.

feat: Optimize Immer performance where possible, introduce `setUseStrictIteration` (#1164)Mark Eriksonbefore adoptione1996ce

lines 78–82why, one step back
78 *
79 * @param obj The object to iterate over80 * @param iter The iterator function81 * @param strict When true (default), includes symbols and non-enumerable properties.82 * When false, uses looseiteration over only enumerable string properties.

fix: Fix handling of Symbol and non-enumerable properties in finalization / freeze. Fixes #1096, #1087, #1091 (#1105))Michel Weststratebefore adoption8949a3e

line 83why, one step back
83 */

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 84–85why, one step back
84export function each<T extends Objectish>(
85 obj: T,

feat: Optimize Immer performance where possible, introduce `setUseStrictIteration` (#1164)Mark Eriksonbefore adoptione1996ce

lines 86–87why, one step back
86 iter: (key: string | number, value: any, source: T) => void,
87 strict?: boolean

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 88why, one step back
88): void

feat: Optimize Immer performance where possible, introduce `setUseStrictIteration` (#1164)Mark Eriksonbefore adoptione1996ce

line 89why, one step back
89export function each(obj: any, iter: any, strict: boolean = true) {

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 90why, one step back
90 if (getArchtype(obj) === ArchType.Object) {

feat: Optimize Immer performance where possible, introduce `setUseStrictIteration` (#1164)Mark Eriksonbefore adoptione1996ce

lines 91–92why, one step back
91 // If strict, we do a full iteration including symbols and non-enumerable properties
92 // Otherwise, we only iterate enumerable string properties for performance

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 93why, one step back
93 const keys = strict ? Reflect.ownKeys(obj) : O.keys(obj)

feat: Optimize Immer performance where possible, introduce `setUseStrictIteration` (#1164)Mark Eriksonbefore adoptione1996ce

line 94why, one step back
94 keys.forEach(key => {

fix: Fix handling of Symbol and non-enumerable properties in finalization / freeze. Fixes #1096, #1087, #1091 (#1105))Michel Weststratebefore adoption8949a3e

line 95why, one step back
95 iter(key, obj[key], obj)

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 96–102why, one step back
96 })
97 } else {98 obj.forEach((entry: any, index: any) => iter(index, entry, obj))99 }100}101102/*#__PURE__*/

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 103why, one step back
103export function getArchtype(thing: any): ArchType {

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 104–105why, one step back
104 const state: undefined | ImmerState = thing[DRAFT_STATE]
105 return state

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 106why, one step back
106 ? state.type_

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 107why, one step back
107 : isArray(thing)

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 108why, one step back
108 ? ArchType.Array

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 109why, one step back
109 : isMap(thing)

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 110why, one step back
110 ? ArchType.Map

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 111why, one step back
111 : isSet(thing)

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

lines 112–113why, one step back
112 ? ArchType.Set
113 : ArchType.Object

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 114–116why, one step back
114}
115116/*#__PURE__*/

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 117–122why, one step back
117export let has = (
118 thing: any,119 prop: PropertyKey,120 type = getArchtype(thing)121): boolean =>122 type === ArchType.Map

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 123why, one step back
123 ? thing.has(prop)

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 124why, one step back
124 : O[PROTOTYPE].hasOwnProperty.call(thing, prop)

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 125–126why, one step back
125
126/*#__PURE__*/

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 127–131why, one step back
127export let get = (
128 thing: AnyMap | AnyObject,129 prop: PropertyKey,130 type = getArchtype(thing)131): any =>

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 132why, one step back
132 // @ts-ignore

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 133why, one step back
133 type === ArchType.Map ? thing.get(prop) : thing[prop]

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 134–135why, one step back
134
135/*#__PURE__*/

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 136–143why, one step back
136export let set = (
137 thing: any,138 propOrOldValue: PropertyKey,139 value: any,140 type = getArchtype(thing)141) => {142 if (type === ArchType.Map) thing.set(propOrOldValue, value)143 else if (type === ArchType.Set) {

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 144–157why, one step back
144 thing.add(value)
145 } else thing[propOrOldValue] = value146}147148/*#__PURE__*/149export function is(x: any, y: any): boolean {150 // From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js151 if (x === y) {152 return x !== 0 || 1 / x === 1 / y153 } else {154 return x !== x && y !== y155 }156}157

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 158–159why, one step back
158export let isArray = Array.isArray
159

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 160why, one step back
160/*#__PURE__*/

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 161why, one step back
161export let isMap = (target: any): target is AnyMap => target instanceof Map

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 162–163why, one step back
162
163/*#__PURE__*/

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 164–173why, one step back
164export let isSet = (target: any): target is AnySet => target instanceof Set
165166export let isObjectish = (target: any) => typeof target === "object"167168export let isFunction = (target: any): target is Function =>169 typeof target === "function"170171export let isBoolean = (target: any): target is boolean =>172 typeof target === "boolean"173

feat: Override array methods to avoid proxy creation while iterating and updating (#1184)Mark Eriksonbefore adoptiond38a9d0

lines 174–178why, one step back
174export function isArrayIndex(value: string | number): value is number | string {
175 const n = +value176 return Number.isInteger(n) && String(n) === value177}178

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 179–181why, one step back
179export let getProxyDraft = <T extends any>(value: T): ImmerState | null => {
180 if (!isObjectish(value)) return null181 return (value as {[DRAFT_STATE]: any})?.[DRAFT_STATE]

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 182why, one step back
182}

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 183why, one step back
183

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 184why, one step back
184/*#__PURE__*/

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 185–189why, one step back
185export let latest = (state: ImmerState): any => state.copy_ || state.base_
186187export let getValue = <T extends object>(value: T): T => {188 const proxyDraft = getProxyDraft(value)189 return proxyDraft ? proxyDraft.copy_ ?? proxyDraft.base_ : value

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 190–191why, one step back
190}
191

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 192–194why, one step back
192export let getFinalValue = (state: ImmerState): any =>
193 state.modified_ ? state.copy_ : state.base_194

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 195why, one step back
195/*#__PURE__*/

feat(performance): Make non-strict mode faster for classes. Addresses #1071Michel Weststratebefore adoption53e3203

line 196why, one step back
196export function shallowCopy(base: any, strict: StrictMode) {

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

lines 197–202why, one step back
197 if (isMap(base)) {
198 return new Map(base)199 }200 if (isSet(base)) {201 return new Set(base)202 }

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 203why, one step back
203 if (isArray(base)) return Array[PROTOTYPE].slice.call(base)

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 204why, one step back
204

feat(performance): Make non-strict mode faster for classes. Addresses #1071Michel Weststratebefore adoption53e3203

line 205why, one step back
205 const isPlain = isPlainObject(base)

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 206why, one step back
206

feat(performance): Make non-strict mode faster for classes. Addresses #1071Michel Weststratebefore adoption53e3203

lines 207–208why, one step back
207 if (strict === true || (strict === "class_only" && !isPlain)) {
208 // Perform a strict copy

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 209why, one step back
209 const descriptors = O.getOwnPropertyDescriptors(base)

feat(performance): Make non-strict mode faster for classes. Addresses #1071Michel Weststratebefore adoption53e3203

lines 210–214why, one step back
210 delete descriptors[DRAFT_STATE as any]
211 let keys = Reflect.ownKeys(descriptors)212 for (let i = 0; i < keys.length; i++) {213 const key: any = keys[i]214 const desc = descriptors[key]

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 215–217why, one step back
215 if (desc[WRITABLE] === false) {
216 desc[WRITABLE] = true217 desc[CONFIGURABLE] = true

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 218why, one step back
218 }

feat(performance): Make non-strict mode faster for classes. Addresses #1071Michel Weststratebefore adoption53e3203

lines 219–223why, one step back
219 // like object.assign, we will read any _own_, get/set accessors. This helps in dealing
220 // with libraries that trap values, like mobx or vue221 // unlike object.assign, non-enumerables will be copied as well222 if (desc.get || desc.set)223 descriptors[key] = {

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 224–227why, one step back
224 [CONFIGURABLE]: true,
225 [WRITABLE]: true, // could live with !!desc.set as well here...226 [ENUMERABLE]: desc[ENUMERABLE],227 [VALUE]: base[key]

feat(performance): Make non-strict mode faster for classes. Addresses #1071Michel Weststratebefore adoption53e3203

lines 228–229why, one step back
228 }
229 }

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 230why, one step back
230 return O.create(getPrototypeOf(base), descriptors)

feat(performance): Make non-strict mode faster for classes. Addresses #1071Michel Weststratebefore adoption53e3203

lines 231–236why, one step back
231 } else {
232 // perform a sloppy copy233 const proto = getPrototypeOf(base)234 if (proto !== null && isPlain) {235 return {...base} // assumption: better inner class optimization than the assign below236 }

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 237–238why, one step back
237 const obj = O.create(proto)
238 return O.assign(obj, base)

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 239–250why, one step back
239 }
240}241242/**243 * Freezes draftable objects. Returns the original object.244 * By default freezes shallowly, but if the second argument is `true` it will freeze recursively.245 *246 * @param obj247 * @param deep248 */249export function freeze<T>(obj: T, deep?: boolean): T250export function freeze<T>(obj: any, deep: boolean = false): T {

Merge pull request #1193 from immerjs/bugfix/1192-non-draftable-valuesMark Eriksonbefore adoption4d2179b

line 251why, one step back
251 if (isFrozen(obj) || isDraft(obj) || !isDraftable(obj)) return obj

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 252why, one step back
252 if (getArchtype(obj) > 1 /* Map or Set */) {

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 253why, one step back
253 O.defineProperties(obj, {

feat: Optimize Immer performance where possible, introduce `setUseStrictIteration` (#1164)Mark Eriksonbefore adoptione1996ce

lines 254–258why, one step back
254 set: dontMutateMethodOverride,
255 add: dontMutateMethodOverride,256 clear: dontMutateMethodOverride,257 delete: dontMutateMethodOverride258 })

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 259why, one step back
259 }

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 260why, one step back
260 O.freeze(obj)

fix: Fix handling of Symbol and non-enumerable properties in finalization / freeze. Fixes #1096, #1087, #1091 (#1105))Michel Weststratebefore adoption8949a3e

lines 261–262why, one step back
261 if (deep)
262 // See #590, don't recurse into non-enumerable / Symbol properties when freezing

Prefix param with underscore to prevent unused param warning (#1145)Alissabefore adoption19cbe47

line 263why, one step back
263 // So use Object.values (only string-like, enumerables) instead of each()

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 264–270why, one step back
264 each(
265 obj,266 (_key, value) => {267 freeze(value, true)268 },269 false270 )

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 271–277why, one step back
271 return obj
272}273274function dontMutateFrozenCollections() {275 die(2)276}277

feat: Optimize Immer performance where possible, introduce `setUseStrictIteration` (#1164)Mark Eriksonbefore adoptione1996ce

line 278why, one step back
278const dontMutateMethodOverride = {

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 279why, one step back
279 [VALUE]: dontMutateFrozenCollections

feat: Optimize Immer performance where possible, introduce `setUseStrictIteration` (#1164)Mark Eriksonbefore adoptione1996ce

lines 280–281why, one step back
280}
281

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 282why, one step back
282export function isFrozen(obj: any): boolean {

feat: Optimize Immer performance where possible, introduce `setUseStrictIteration` (#1164)Mark Eriksonbefore adoptione1996ce

line 283why, one step back
283 // Fast path: primitives and null/undefined are always "frozen"

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 284–285why, one step back
284 if (obj === null || !isObjectish(obj)) return true
285 return O.isFrozen(obj)

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 286why, one step back
286}