File tree 2 files changed +11
-2
lines changed
2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @yamada-ui/utils ' : patch
3
+ ---
4
+
5
+ Added ` omitKeys ` parameter to ` flattenObject ` function.
Original file line number Diff line number Diff line change @@ -99,12 +99,16 @@ export const merge = <T extends Dict>(
99
99
export const flattenObject = < T extends Dict > (
100
100
obj : any ,
101
101
maxDepth : number = Infinity ,
102
+ omitKeys : string [ ] = [ ] ,
102
103
) : T => {
103
104
if ( ( ! isObject ( obj ) && ! isArray ( obj ) ) || ! maxDepth ) return obj
104
105
105
106
return Object . entries ( obj ) . reduce ( ( result , [ key , value ] ) => {
106
- if ( isObject ( value ) ) {
107
- Object . entries ( flattenObject ( value , maxDepth - 1 ) ) . forEach (
107
+ if (
108
+ isObject ( value ) &&
109
+ ! Object . keys ( value ) . some ( ( key ) => omitKeys . includes ( key ) )
110
+ ) {
111
+ Object . entries ( flattenObject ( value , maxDepth - 1 , omitKeys ) ) . forEach (
108
112
( [ childKey , childValue ] ) => {
109
113
result [ `${ key } .${ childKey } ` ] = childValue
110
114
} ,
You can’t perform that action at this time.
0 commit comments