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:
parent
6f48c526c6
commit
568b7d6afb
1 changed files with 3 additions and 6 deletions
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue