diff options
author | Behnam Mohammadi <itten@live.com> | 2020-11-10 02:13:44 +0330 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-10 09:43:44 +1100 |
commit | 568b7d6afb43d7f501d1baf14d5a10470541bba2 (patch) | |
tree | 69fe8a4564be3f71ac69839a2a92cc0ac9f4e82b /std/fs | |
parent | 6f48c526c6ad1260020e099011c9496476c0fce3 (diff) |
refactor(std/fs): improve performance by using some instead filter method (#8322)
Diffstat (limited to 'std/fs')
-rw-r--r-- | std/fs/eol.ts | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/std/fs/eol.ts b/std/fs/eol.ts index 2f15be269..5ea554c6e 100644 --- a/std/fs/eol.ts +++ b/std/fs/eol.ts @@ -17,12 +17,9 @@ export function detect(content: string): EOL | null { if (!d || d.length === 0) { return null; } - const crlf = d.filter((x: string): boolean => x === EOL.CRLF); - if (crlf.length > 0) { - return EOL.CRLF; - } else { - return EOL.LF; - } + const hasCRLF = d.some((x: string): boolean => x === EOL.CRLF); + + return hasCRLF ? EOL.CRLF : EOL.LF; } /** Format the file to the targeted EOL */ |