@hugoalh/eol
v0.5.1
Published
A module to handle end of line (EOL).
Readme
End Of Line (EOL) (ES)
🔗 DistBoard @hugoalh ● GitHub ● JSR ● NPM
An ECMAScript module to handle end of line (EOL).
🎯 Runtime Targets
Any runtime which support ECMAScript should able to use this; These runtimes are officially supported:
🛡️ Runtime Permissions
This does not request any runtime permission.
#️⃣ Sources & Entrypoints
- GitHub Raw
https://raw.githubusercontent.com/hugoalh/eol-es/{Tag}/mod.ts - JSR
jsr:@hugoalh/eol[@{Tag}] - NPM
npm:@hugoalh/eol[@{Tag}]
| Name | Path | Description |
|:--|:--|:--|
| . | ./mod.ts | Default. |
| ./detect | ./detect.ts | Detect. |
| ./eol | ./eol.ts | Basic. |
| ./line | ./line.ts | Line. |
| ./normalize | ./normalize.ts | Normalize. |
[!NOTE]
- Different runtimes have vary support for the sources and entrypoints, visit the runtime documentation for more information.
- 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).
🧩 APIs
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:
✍️ Examples
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"); //=> nullnormalizeEOL(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)
