JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7101
  • Score
    100M100P100Q138061F
  • License MIT

Determine EOL based on given text and OS.

Package Exports

  • @dozerg/end-of-line

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@dozerg/end-of-line) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

End-of-line

Determine EOL based on given text and OS.

Install

npm i @dozerg/end-of-line

Usage

import { endOfLine } from '@dozerg/end-of-line';

// Detect OS-specific EOL.
const default_eol = endOfLine();

// Detect EOL for a given text.
const text = 'some\ntext\nwith\r\nnewlines\r';
const eol = endOfLine(text); // '\n'

APIs

function endOfLine(): string

Determine the OS-specific end-of-line marker. Equivalent to os.EOL.

function endOfLine(text: string): string

Determine end-of-line marker for a given text. The following markers will be recognized:

  • \n
  • \r\n
  • \r
  • \n\r

If there is no EOL found, os.EOL will be returned.

License

MIT