Newline character converter node module for JavaScript or TypeScript
npm install eol
\r\n
or \n
\r\n
\n
\r
eol.auto
linebreakeol.lf(eol.before(text))
⋮eol.auto
linebreakeol.lf(eol.after(text))
⋮Coercing normalizers to string yields the appropriate character...useful glue for joining
String(eol.lf) // "\n"
eol.split(text).join(eol.auto) // === 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
Detect or inspect via match
eol.match(" ") // []
eol.match("world\nwide\nweb") // ["\n","\n"]
Generate alternate normalizers
let extra = eol.dub("\n\n\n")
extra("...")
let huh = eol.dub("???")
huh("...")
let eol = require("eol")
let edit = require("edit-file")
edit("sample.txt", eol.lf)
let eol = require("eol")
let map = require("map-file")
map({
from: "from.txt",
to: "to.txt",
map: eol.lf
})
let ssv = require("ssv")
let eol = require("eol")
let deep = eol.split("spaced.txt").map(ssv.split)
Have an eol
sample to share?
Then please do 🧪 🧪 🧪 🧪