Skip to content

Commit 02185cd

Browse files
committed
fix: No flat, for compatibility. #117
1 parent 6dc25c9 commit 02185cd

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/utils/index.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ export function jsonFlatten(
3535
level = 0,
3636
options?: JSONFlattenOptions,
3737
): JSONFlattenReturnType[] {
38-
const { key, index, type = 'content', showComma = false, length = 1 } =
39-
options || ({} as JSONFlattenOptions);
38+
const {
39+
key,
40+
index,
41+
type = 'content',
42+
showComma = false,
43+
length = 1,
44+
} = options || ({} as JSONFlattenOptions);
4045
const dataType = getDataType(data);
4146

4247
if (dataType === 'array') {
@@ -49,7 +54,8 @@ export function jsonFlatten(
4954
type,
5055
}),
5156
)
52-
.flat();
57+
// No flat, for compatibility.
58+
.reduce((acc, val) => acc.concat(val), []);
5359
return [
5460
jsonFlatten('[', path, level, {
5561
showComma: false,
@@ -81,7 +87,8 @@ export function jsonFlatten(
8187
},
8288
),
8389
)
84-
.flat();
90+
// No flat, for compatibility.
91+
.reduce((acc, val) => acc.concat(val), []);
8592
return [
8693
jsonFlatten('{', path, level, {
8794
showComma: false,

0 commit comments

Comments
 (0)