mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
refactor(fs): use every instead of reduce (#5323)
The previous usage of `reduce` was basically implementing the `every` A small difference is that the new implementation will stop checking as soon as one element have returned false, which will reduce the number of unnecessary checks.
This commit is contained in:
parent
89fe81168e
commit
8228ea85fd
1 changed files with 1 additions and 5 deletions
|
@ -16,11 +16,7 @@ export function isSubdir(
|
|||
}
|
||||
const srcArray = src.split(sep);
|
||||
const destArray = dest.split(sep);
|
||||
// see: https://github.com/Microsoft/TypeScript/issues/30821
|
||||
// @ts-ignore
|
||||
return srcArray.reduce((acc: true, current: string, i: number): boolean => {
|
||||
return acc && destArray[i] === current;
|
||||
}, true);
|
||||
return srcArray.every((current, i) => destArray[i] === current);
|
||||
}
|
||||
|
||||
export type PathType = "file" | "dir" | "symlink";
|
||||
|
|
Loading…
Add table
Reference in a new issue