@@ -98,15 +98,23 @@ export function original(value: Drafted<any>): any {
9898/**
9999 * Each iterates a map, set or array.
100100 * Or, if any other kind of object, all of its own properties.
101- * Regardless whether they are enumerable or symbols
101+ *
102+ * @param obj The object to iterate over
103+ * @param iter The iterator function
104+ * @param strict When true (default), includes symbols and non-enumerable properties.
105+ * When false, uses ultra-fast iteration over only enumerable string properties.
102106 */
103107export function each < T extends Objectish > (
104108 obj : T ,
105- iter : ( key : string | number , value : any , source : T ) => void
109+ iter : ( key : string | number , value : any , source : T ) => void ,
110+ strict ?: boolean
106111) : void
107- export function each ( obj : any , iter : any ) {
112+ export function each ( obj : any , iter : any , strict : boolean = true ) {
108113 if ( getArchtype ( obj ) === ArchType . Object ) {
109- Reflect . ownKeys ( obj ) . forEach ( key => {
114+ // If strict, we do a full iteration including symbols and non-enumerable properties
115+ // Otherwise, we only iterate enumerable string properties for performance
116+ const keys = strict ? Reflect . ownKeys ( obj ) : Object . keys ( obj )
117+ keys . forEach ( key => {
110118 iter ( key , obj [ key ] , obj )
111119 } )
112120 } else {
0 commit comments