An ECMAScript module to handle end of line (EOL).
| Runtime \ Source | GitHub Raw | JSR | NPM |
|---|---|---|---|
| Bun >= v1.1.0 | ❌ | ✔️ | ✔️ |
| Deno >= v2.1.0 | ✔️ | ✔️ | ✔️ |
| NodeJS >= v20.9.0 | ❌ | ✔️ | ✔️ |
This does not request any runtime permission.
- GitHub Raw
https://raw.githubusercontent.com/hugoalh/eol-es/{Tag}/mod.ts - JSR
jsr:@hugoalh/eol[@{Tag}] - NPM
npm:@hugoalh/eol[@{Tag}]
Note
- It is recommended to include tag for immutability.
- These are not part of the public APIs hence should not be used:
- Benchmark/Test file (e.g.:
example.bench.ts,example.test.ts). - Entrypoint name or path include any underscore prefix (e.g.:
_example.ts,foo/_example.ts). - Identifier/Namespace/Symbol include any underscore prefix (e.g.:
_example,Foo._example).
- Benchmark/Test file (e.g.:
| Name | Path | Description |
|---|---|---|
. |
./mod.ts |
Default. |
./detect |
./detect.ts |
Detect. |
./eol |
./eol.ts |
Basic. |
./line |
./line.ts |
Line. |
./normalize |
./normalize.ts |
Normalize. |
-
class EOLNormalizeStream extends TransformStream<string, string> { constructor(eol: EOLCharacter); }
-
class LineStream extends TransformStream<string, string> { }
-
function detectEOL(content: string): EOLCharacter | null;
-
function detectEOLFromStream(stream: ReadableStream<string>): Promise<EOLCharacter | null>;
-
function normalizeEOL(eol: EOLCharacter, content: string): string;
-
type EOLCharacter = | typeof eolCRLF | typeof eolLF;
Note
- For the full or prettier documentation, can visit via:
-
detectEOL("Deno\r\nis not\r\nNode"); //=> "\r\n"
-
detectEOL("Deno\nis not\r\nNode"); //=> "\r\n"
-
detectEOL("Deno\nis not\nNode"); //=> "\n"
-
detectEOL("Deno is not Node"); //=> null
-
normalizeEOL(eolCurrent, "Deno\r\nis not\r\nNode"); //=> "Deno\nis not\nNode" (POSIX/UNIX Platforms) //=> "Deno\r\nis not\r\nNode" (Windows Platforms)
-
normalizeEOL(eolLF, "Deno\r\nis not\r\nNode"); //=> "Deno\nis not\nNode" (POSIX/UNIX Platforms) //=> "Deno\nis not\nNode" (Windows Platforms)