diff --git a/README.md b/README.md index a7a019e..0a4f6ce 100644 --- a/README.md +++ b/README.md @@ -18,42 +18,42 @@ import eol from 'eol' ## API ### `eol.auto(text)` -- Normalize line endings in text for the current operating system -- @return string with line endings normalized to `\r\n` or `\n` +* 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) -- @return string with line endings normalized to `\r\n` +* 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) -- @return string with line endings normalized to `\n` +* 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) -- @return string with line endings normalized to `\r` +* Normalize line endings in text to CR (Mac OS) +* Returns string with line endings normalized to `\r` ### `eol.dub(text)` - [Dubnormalize.](https://github.com/ryanve/eol/pull/32) [Used internally.](eol.js) [Generative.](#dubbing) - Create normalizer where linebreaks become text -- @return composed function +- Returns composed function ### `eol.before(text)` - Add linebreak before text -- @return string with linebreak added before text +- Returns string with linebreak added before text ### `eol.after(text)` - Add linebreak after text -- @return string with linebreak added after text +- Returns string with linebreak added after text ### `eol.match(text)` - Detect or inspect linebreaks in text -- @return array of matched linebreaks +- Returns array of matched linebreaks ### `eol.split(text)` - Split text by newline -- @return array of lines +- Returns array of lines ### Joining diff --git a/index.html b/index.html index 36cddb6..40fdd3f 100644 --- a/index.html +++ b/index.html @@ -1,38 +1,132 @@ - + -EOL converter - - + +EOL opensource library + + + + + + + + + + + + -
-

eol converter

- Github - npm +
+

+ eol + opensource + newline + conversion +

+ +

+ eol is an opensource + newline + conversion node module. + eol helps you smoothly convert line endings + in node applications. + eol is written in JavaScript and supports TypeScript too. + The words newline, linebreak, line ending + are used interchangeably here. + They mark an end of line. + Feel free to play with eol + in the console on this page for learning purposes. +

-
-
- - - -
-
-

Output

-
-
-
+
+

methods

+
+
eol.auto(text) +
Normalize text to match the current operating system +
Returns string with line endings normalized accordingly +
eol.crlf(text) +
Normalize line endings in text to CRLF (Windows, DOS) +
Returns string normalized to \r\n line endings +
eol.lf(text) +
Normalize line endings in text to LF (Unix, OS X) +
Returns string normalized to \n line endings +
eol.cr(text) +
Normalize line endings in text to CR (Mac OS) +
Returns string normalized to \r line endings +
eol.dub(text) +
Generate normalizer that replaces line endings with text +
Returns composed function like above +
Usable as glue to join arrays +
eol.before(text) +
Add linebreak before text +
Returns string with linebreak added before text +
eol.after(text) +
Add linebreak after text +
Returns string with linebreak added 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 +
+
+ +
+

samples

+

normalizing

+
eol.lf("hello\r\nworld\r\n")
// "hello\nworld\n"
+

remove empty lines

+
eol.split(text).filter(line => line).join(eol.lf)
+

detect or inspect

+
eol.match("hello\nworld\n")
// ["\n","\n"]
+

coercion

+
String(eol.lf) // "\n"
+
String(eol.cr) // "\r"
+
String(eol.crlf) // "\r\n"
+

generating normalizers

+
let lflf = eol.dub("\n\n")
lflf("hello\nworld\n")
// "hello\n\nworld\n\n"
+
+ + - - diff --git a/style.css b/style.css index 523ed1e..4a443f3 100644 --- a/style.css +++ b/style.css @@ -1,81 +1,90 @@ -.scheme--white { background: whitesmoke; color: black } -.scheme--dark { background: blue; color: whitesmoke } -.scheme--light { background: gainsboro; color: blue } -:focus { outline-color: blue } - -*, :before, :after { box-sizing: border-box } -html { font: 1em/2 sans-serif; } -body { width: 100%; margin: auto; padding: 1em } -a { text-decoration: none } -a:hover { text-decoration: underline } -textarea, select { font: inherit } -textarea { max-width: 100%; margin: 0 } -header, section { display: block } -fieldset { padding: 0; border: 0 } -label { margin: 0; padding: 0 } -h1, h2 { line-height: 1 } - -.border-radius { - border-radius: .25em; -} - -.inherit-size { - font-size: inherit; -} - -.button { - font-size: inherit; - font-style: inherit; - font-weight: bold; - min-height: 2.5em; - display: inline-block; - border: 0; - border-radius: .25em; - padding: .33333em .66666em; - margin: 0; +:focus { + box-shadow: 0 0 1ch 1ch var(--yffi, currentColor); + outline: thick dotted var(--iffy, currentColor); +} + +:any-link:hover { + text-decoration-style: double; +} + +* { + box-sizing: border-box; } -.button:focus { - text-decoration: underline; +html { + font-family: sans-serif; + font-size: max(3ch, 2vw + 1vh); + line-height: 1.618; } -.button:enabled:hover { - cursor: pointer; - text-decoration: underline; +body { + display: flex; + flex-flow: column; + margin: auto; + overflow-wrap: anywhere; } -.m-b-1 { - margin-bottom: .5em; +body > * { + contain: layout; + padding: 1em; + padding-block: calc(1em + 1vh); + padding-inline: calc(1em + 1vw); } -.m-b-2 { - margin-bottom: 1em; +a:only-child, +nav a { + padding: .5ch; } -.m-b-3 { + { + padding: .5ch; +} + +header { margin-bottom: 2em; } -.inline-block { - display: inline-block; +pre { + font-family: monospace; + white-space: pre-line; } -.block { - display: block; +p { + max-width: 26em; + margin-inline: auto; } -.area { - white-space: pre-wrap; - border: 2px solid gainsboro; - padding: .25em; - display: block; - overflow: auto; - resize: vertical; - width: 100%; - height: 7.5em; - line-height: 1.1; +dt { + font-size: 1.236rem; + margin-block: 1em 0; } -.text--uppercase { - text-transform: uppercase; -} \ No newline at end of file +dd { + margin-block: 0; +} + +pre { + font-size: 0.666rem; + margin: 0; +} + +q { + font-family: monospace; + quotes: '"' '"'; +} + +h1 { + font-size: 1.618em; + font-weight: unset; + margin-bottom: 1ch; +} + +h2 { + font-size: 1.382em; +} + +dfn, +cite { + font-style: unset; + font-weight: bold; +} diff --git a/ui.js b/ui.js deleted file mode 100644 index 354320f..0000000 --- a/ui.js +++ /dev/null @@ -1,9 +0,0 @@ -/* global eol */ -$('.js-converter__form').on('submit', function(e) { - e.preventDefault() - var $form = $(this) - var $output = $form.find('.js-converter__output') - var method = $form.find('.js-converter__method')[0].value - var text = $form.find('.js-converter__input')[0].value - $output.text(eol[method](text)) -});