eol-utils
v1.0.1
Published
Easy-to-use regex functions to format line breaks as Carriage Return Line Feed _CR LF_ (Windows), Line Feed _LF_ (Unix) and Carriage Return _CR_ (Mac OS <= 9).
Downloads
112
Maintainers
Readme
eol-utils
Easy-to-use regex functions to format line breaks as Carriage Return Line Feed CR LF (Windows), Line Feed LF (Unix) and Carriage Return CR (Mac OS <= 9).
Installation
npm i eol-utils
Usage
Import the desired function(s) and pass in a string to normalize its line breaks.
import { crlf, lf, cr } from 'eol-utils';
let str = '\rHello\nWorld\r\n';
console.log(crlf(str)); // --> '\r\nHello\r\nWorld\r\n'
console.log(lf(str)); // --> '\nHello\nWorld\n'
console.log(cr(str)); // --> '\rHello\rWorld\r'
Contributing
Contributions welcome.
License
The MIT License (MIT) 2024 - clhilgert. Please refer to LICENSE for more details.