Skip to content

hugoalh/eol-es

End Of Line (EOL) (ES)

⚖️ MIT

GitHub: hugoalh/eol-es JSR: @hugoalh/eol NPM: @hugoalh/eol

An ECMAScript module to handle end of line (EOL).

🎯 Targets

Runtime \ Source GitHub Raw JSR NPM
Bun >= v1.1.0 ✔️ ✔️
Deno >= v2.1.0 ✔️ ✔️ ✔️
NodeJS >= v20.9.0 ✔️ ✔️

🛡️ Runtime Permissions

This does not request any runtime permission.

#️⃣ Sources

  • 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).

⤵️ Entrypoints

Name Path Description
. ./mod.ts Default.
./detect ./detect.ts Detect.
./eol ./eol.ts Basic.
./line ./line.ts Line.
./normalize ./normalize.ts Normalize.

🧩 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

✍️ 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");
    //=> 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)

About

An ECMAScript module to handle end of line (EOL).

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •