@@ -73,28 +73,28 @@ export const anyOn = (set: Set<string>, names?: NamePath[]) =>
7373export const allOn = ( set : Set < string > , names ?: NamePath [ ] ) =>
7474 ! names || names . length === 0 ? set . size > 0 : names . every ( n => set . has ( keyOfName ( n ) ) ) ;
7575
76- // ✅ 递归收集变更路径(会把数组也往里走)
76+ // ✅ Recursively collect changed paths (descend into arrays as well)
7777export const collectChangedLeafPaths = (
7878 input : any ,
7979 prefix : ( string | number ) [ ] = [ ] ,
8080 out : ( string | number ) [ ] [ ] = [ ]
8181) => {
8282 if ( Array . isArray ( input ) ) {
83- // 数组节点本身也视为变更(用于 List 层级)
83+ // Array nodes themselves are also treated as changes (used by List level)
8484 out . push ( [ ...prefix ] ) ;
8585 input . forEach ( ( item , i ) => collectChangedLeafPaths ( item , [ ...prefix , keyOfName ( i ) ] , out ) ) ;
8686 } else if ( input && typeof input === 'object' ) {
8787 Object . keys ( input ) . forEach ( k => {
8888 collectChangedLeafPaths ( input [ keyOfName ( k ) ] , [ ...prefix , keyOfName ( k ) ] , out ) ;
8989 } ) ;
9090 } else {
91- // 原子值,叶子
91+ // Atomic value, leaf
9292 out . push ( [ ...prefix ] ) ;
9393 }
9494 return out ;
9595} ;
9696
97- // ✅ 如果想覆盖“删除/缩短数组”的场景(通知旧叶子),可以把旧值的叶子也并上
97+ // ✅ To cover cases like array deletion/shortening (to notify old leaves), union with the old value's leaves as well
9898export const unionPaths = ( a : ( string | number ) [ ] [ ] , b : ( string | number ) [ ] [ ] ) => {
9999 const s = new Set < string > ( ) ;
100100 const res : ( string | number ) [ ] [ ] = [ ] ;
@@ -123,19 +123,19 @@ export const isUnderPrefix = (key: string, prefix: string): boolean => {
123123
124124export function collectDeepKeys ( obj : any , prefix : string = '' ) : string [ ] {
125125 if ( obj === null || obj === undefined ) {
126- // 叶子节点(值是 null/undefined)
126+ // Leaf node (value is null/undefined)
127127 return [ prefix ] ;
128128 }
129129
130130 if ( typeof obj !== 'object' || obj instanceof Date ) {
131- // 基础值( string/number/boolean/function/Date...)
131+ // Primitive value ( string/number/boolean/function/Date...)
132132 return [ prefix ] ;
133133 }
134134
135- // 对象/数组:即使值是 undefined/null,也要保留路径
135+ // Object/Array: keep the path even if value is undefined/null
136136 const keys : string [ ] = [ ] ;
137137
138- // 如果是空对象/数组,也要把自己 push 出来
138+ // If empty object/array, also push itself
139139 if ( Object . keys ( obj ) . length === 0 ) {
140140 keys . push ( prefix ) ;
141141 return keys ;
0 commit comments