Skip to content

Commit badfe9f

Browse files
removing .flat function to get rid of its dependency (#1105)
1 parent a4d74b9 commit badfe9f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

node/task.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ export function ls(optionsOrPaths?: unknown, ...paths: unknown[]): string[] {
10471047

10481048
// Flatten paths if the paths argument is array
10491049
if (Array.isArray(paths)) {
1050-
paths = paths.flat(Infinity);
1050+
paths = flattenArray(paths);
10511051
}
10521052

10531053
// If the first argument is not options, then it is a path
@@ -1121,6 +1121,12 @@ export function ls(optionsOrPaths?: unknown, ...paths: unknown[]): string[] {
11211121
}
11221122
}
11231123

1124+
function flattenArray(arr: any[]): any[] {
1125+
return arr.reduce((flat, toFlatten) => {
1126+
return flat.concat(Array.isArray(toFlatten) ? flattenArray(toFlatten) : toFlatten);
1127+
}, []);
1128+
}
1129+
11241130
type CopyOptionsVariants = OptionsPermutations<'frn'>;
11251131

11261132
/**

0 commit comments

Comments
 (0)