Newline character converter for JavaScript. Available on npm.
npm install eol --save
require or importconst eol = require('eol')
import eol from 'eol'
eol.auto(text)\r\n or \neol.crlf(text)\r\neol.lf(text)\neol.cr(text)\reol.before(text)eol.after(text)eol.split(text)Coercing eol.auto|eol.crlf|eol.lf|eol.cr to string yields the appropriate character. This is useful for joining.
String(eol.lf) // "\n"
eol.split(text).join(eol.auto) // same as eol.auto(text)
eol.split(text).filter(line => line).join(eol.auto) // text joined after removing empty lines
eol.split(text).slice(-3).join(eol.auto) // last 3 lines joined
MIT
Copyright 2013 - present © cnpmjs.org