1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-29 16:30:56 -05:00

refactor(std/fs): improve performance by using some instead filter method (#8322)

This commit is contained in:
Behnam Mohammadi 2020-11-10 02:13:44 +03:30 committed by GitHub
parent 6f48c526c6
commit 568b7d6afb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 */