@@ -31,20 +31,24 @@ interface ProducersFns {
3131 produceWithPatches : IProduceWithPatches
3232}
3333
34- export type StrictMode = boolean | "class_only" ;
34+ export type StrictMode = boolean | "class_only"
3535
3636export class Immer implements ProducersFns {
3737 autoFreeze_ : boolean = true
3838 useStrictShallowCopy_ : StrictMode = false
39+ useStrictIteration_ : boolean = false
3940
4041 constructor ( config ?: {
4142 autoFreeze ?: boolean
4243 useStrictShallowCopy ?: StrictMode
44+ useStrictIteration ?: boolean
4345 } ) {
4446 if ( typeof config ?. autoFreeze === "boolean" )
4547 this . setAutoFreeze ( config ! . autoFreeze )
4648 if ( typeof config ?. useStrictShallowCopy === "boolean" )
4749 this . setUseStrictShallowCopy ( config ! . useStrictShallowCopy )
50+ if ( typeof config ?. useStrictIteration === "boolean" )
51+ this . setUseStrictIteration ( config ! . useStrictIteration )
4852 }
4953
5054 /**
@@ -172,6 +176,20 @@ export class Immer implements ProducersFns {
172176 this . useStrictShallowCopy_ = value
173177 }
174178
179+ /**
180+ * Pass false to use faster iteration that skips non-enumerable properties
181+ * but still handles symbols for compatibility.
182+ *
183+ * By default, strict iteration is enabled (includes all own properties).
184+ */
185+ setUseStrictIteration ( value : boolean ) {
186+ this . useStrictIteration_ = value
187+ }
188+
189+ shouldUseStrictIteration ( obj : any ) : boolean {
190+ return this . useStrictIteration_
191+ }
192+
175193 applyPatches < T extends Objectish > ( base : T , patches : readonly Patch [ ] ) : T {
176194 // If a patch replaces the entire state, take that replacement as base
177195 // before applying patches
0 commit comments