summaryrefslogtreecommitdiff
path: root/std/fs/_util.ts
diff options
context:
space:
mode:
authorLinus Unnebäck <linus@folkdatorn.se>2020-05-15 19:53:23 +0100
committerGitHub <noreply@github.com>2020-05-15 20:53:23 +0200
commit8228ea85fd610d5496a3240538f15d2f4eed1d87 (patch)
tree5fd270d3107216a3aee306b99207c05abf022919 /std/fs/_util.ts
parent89fe81168e75a375a67e9d391b367d2a9749153c (diff)
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.
Diffstat (limited to 'std/fs/_util.ts')
-rw-r--r--std/fs/_util.ts6
1 files changed, 1 insertions, 5 deletions
diff --git a/std/fs/_util.ts b/std/fs/_util.ts
index aecd9748b..bae48c970 100644
--- a/std/fs/_util.ts
+++ b/std/fs/_util.ts
@@ -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";