0.10.0 • Published 10 months ago

eol v0.10.0

Weekly downloads
642,819
License
MIT
Repository
github
Last release
10 months ago

eol

Newline character converter node module for JavaScript or TypeScript

npm.im/eol

  • npm install eol
  • let eol = require("eol")
  • import eol from "eol"

API

eol.auto(text)

  • Normalize line endings in text to match the current operating system
  • Returns string with line endings normalized to \r\n or \n

eol.crlf(text)

  • Normalize line endings in text to CRLF (Windows, DOS)
  • Returns string with line endings normalized to \r\n

eol.lf(text)

  • Normalize line endings in text to LF (Unix, OS X)
  • Returns string with line endings normalized to \n

eol.cr(text)

  • Normalize line endings in text to CR (Mac OS)
  • Returns string with line endings normalized to \r

eol.dub(text)

eol.before(text)

  • Add linebreak before text
  • Returns string with linebreak added before text
  • Uses eol.auto linebreak
  • eol.lf(eol.before(text))

eol.after(text)

  • Add linebreak after text
  • Returns string with linebreak added after text
  • Uses eol.auto linebreak
  • eol.lf(eol.after(text))

eol.match(text)

  • Detect or inspect linebreaks in text
  • Returns array of matched linebreaks

eol.split(text)

  • Split text by newline
  • Returns array of lines

Joining

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

Matching

Detect or inspect via match

eol.match(" ") // []
eol.match("world\nwide\nweb") // ["\n","\n"]

Dubbing

Generate alternate normalizers

let extra = eol.dub("\n\n\n")
extra("...")
let huh = eol.dub("???")
huh("...")

modularitY

edit-file

let eol = require("eol")
let edit = require("edit-file")

edit("sample.txt", eol.lf)

map-file

let eol = require("eol")
let map = require("map-file")

map({
  from: "from.txt",
  to: "to.txt",
  map: eol.lf
})

ssv

let ssv = require("ssv")
let eol = require("eol")

let deep = eol.split("spaced.txt").map(ssv.split)

Yours

Have an eol sample to share?

Then please do :test_tube: :test_tube: :test_tube: :test_tube:

opensource

MIT License

∞/0

alebusse@dockbite/ng-openapi-genazure-devops-utilssheepskininova-openapi-codegeni18n-binesante-api@everything-registry/sub-chunk-1590synpsynp2test-jailwhitesourcewomplib.jsweapp-openapi-genspotgenthe-judgetextrun-repo@contentpass/i18next-scannerjachavaljichaolijest-dir-snapshotjiclibitgojesh-calculationkeyring-pgplambeelambee-clii18next-parser-async-translatealize-api-gensql-source-controlsql-source-control-pslsourcejs-reactspace-ui-core-frameworksoliumtyler-bitgojs-testingtxt2utf8typed-static-filestutorial-runner@antongolub/synp@apib/2postman@apache-royale/royale-js-swf@arielapaula/components@arielapaula/test@aviinash_jha/react-native-test_multiply@adobe/ccweb-add-on-devcert@alexciesielski/ng-openapi-gen@aloe2/sdk-api@bitgo/sdk-api@bitgo-beta/sdk-api@blendsdk/codekit@childrentime/devcert@certin/core@adlk/i18next-parser@a-morphous/recital@a-morphous/recital-ext-common-commands@77io/sh-script-builder@bepo65/license-report@brandonkal/devcert@dhoeppe/ng-openapi-gen@credenceanalytics/credclizeysdkuntitled-code-generator@huksley/spectral@edwinpb/scany@eui/tools@fullstax/ng-openapi-gen@genese/api@genese/complexity@informalsystems/quint@infinitebrahmanuniverse/nolb-eo@labiebhn_/react-native-multiplier@kuimo/i18next-scanner@loopmode/babel-plugin-react-intl-messages-generator@manuth/generator-my-ts-project@manuth/generator-ts-project@nbellanich/bitgo@nix2/service-core@expo/devcert@erengee/ng-openapi-gen@fabien0102/i18next-parser@mike-north/devcert-patched@jzetlen/devcert@kie/npm-treatment-tool@jeremyhon/i18next-scanner@qoollo/ng-openapi-gen@public-js/ng-openapi-gen@ryan-bitgo/bitgo@radon-extension/build@recital/stage-parser@o/devcert@sensebox/sketch-templater@rewind-media/rewind-workermeyerom-test1of-coursenpm-user-switchpaperchase-apipaperchase-pmcpassbolt-i18next-scannersc60roku-debug
0.10.0

10 months ago

0.9.1

8 years ago

0.9.0

8 years ago

0.8.1

8 years ago

0.8.0

8 years ago

0.7.0

8 years ago

0.6.0

8 years ago

0.5.1

8 years ago

0.5.0

8 years ago

0.4.0

9 years ago

0.3.0

9 years ago

0.2.0

11 years ago

0.1.0

11 years ago