1.0.17 • Published 29 days ago

@dozerg/end-of-line v1.0.17

Weekly downloads
22
License
MIT
Repository
github
Last release
29 days ago

End-of-line

npm Downloads Build Status

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 text_eol = endOfLine(text); // '\n'

// Detect EOL for a file.
const filename = '/path/to/file.ext';
const file_eol = endOfLineForFile(filename);

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.

function endOfLineForFile(filePath: string): string

Determine end-of-line marker for a given file.

If file doesn't exist or cannot be read, os.EOL will be returned.

License

MIT

1.0.17

29 days ago

1.0.16

5 months ago

1.0.15

5 months ago

1.0.14

8 months ago

1.0.11

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.9

2 years ago

1.0.10

2 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago