@@ -133,7 +133,7 @@ export function arrFlat<T extends unknown[]>(arr: T): unknown[] {
133
133
}
134
134
135
135
export function cloneDeep < T extends unknown > ( source : T , hash = new WeakMap ( ) ) : T {
136
- if ( source === null ) return source ;
136
+ if ( source === null || source === undefined ) return source ;
137
137
if ( source instanceof Date ) return new Date ( source ) as T ;
138
138
if ( source instanceof RegExp ) return new RegExp ( source ) as T ;
139
139
if ( typeof source !== 'object' ) return source ;
@@ -171,79 +171,3 @@ export function stringToAutoType(source: string): unknown {
171
171
}
172
172
return value ;
173
173
}
174
-
175
- // function jsonFlattenNext(data: JSONDataType, path = 'root'): JSONFlattenReturnType[] {
176
- // function test(content: unknown, path: string, level: number, options: JSONFlattenOptions) {
177
- // const { type = 'content', key, index, showComma, length } = options || {};
178
- // return {
179
- // content,
180
- // level,
181
- // key,
182
- // index,
183
- // path,
184
- // showComma,
185
- // length,
186
- // type,
187
- // };
188
- // }
189
-
190
- // let endObj = {} as Record<string, unknown>;
191
- // let i = 0;
192
- // let output: any = [data];
193
- // let startArr = [];
194
- // while (output.length || endObj[i]) {
195
- // if (i && endObj[i]) {
196
- // const k = endObj[i];
197
- // delete endObj[i];
198
- // startArr.push(k);
199
- // i++;
200
- // } else {
201
- // const now = output.shift();
202
- // if (Array.isArray(now)) {
203
- // startArr.push(
204
- // test('[', path, 0, {
205
- // type: 'arrayStart',
206
- // showComma: false,
207
- // length: now.length,
208
- // }),
209
- // );
210
- // output = now.concat(output);
211
- // Object.keys(endObj)
212
- // .sort((a, b) => Number(b) - Number(a))
213
- // .forEach(id => {
214
- // endObj[Number(id) + now.length + 1] = endObj[id];
215
- // delete endObj[id];
216
- // });
217
- // endObj[i + now.length] = ']';
218
- // } else if (typeof now === 'object') {
219
- // startArr.push(
220
- // test('{', path, 0, {
221
- // type: 'objectStart',
222
- // showComma: false,
223
- // length: Object.keys(now).length,
224
- // }),
225
- // );
226
- // output = Object.keys(now)
227
- // .map(key => now[key])
228
- // .concat(output);
229
- // Object.keys(endObj)
230
- // .sort((a, b) => Number(b) - Number(a))
231
- // .forEach(id => {
232
- // endObj[Number(id) + Object.keys(now).length + 1] = endObj[id];
233
- // delete endObj[id];
234
- // });
235
- // endObj[i + Object.keys(now).length] = ' }';
236
- // } else {
237
- // startArr.push(
238
- // test(now, path, 0, {
239
- // type: 'content',
240
- // showComma: false,
241
- // length: 0,
242
- // }),
243
- // );
244
- // }
245
- // }
246
- // }
247
-
248
- // return startArr as any;
249
- // }
0 commit comments