Debian Codegraph @

eol/index.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html lang="en-US" class="iffy">
3 <meta charset="utf-8">
4
5 <title>EOL opensource library</title>
6
7 <meta name="viewport" content="width=device-width">
8 <meta name="description" content="JavaScript newline conversion library">
9 <meta name="color-scheme" content="dark light">
10 <meta name="theme-color" content="darkviolet">
11
12 <link rel="help" href="https://github.com/ryanve/eol#readme">
13 <link rel="help" href="https://en.wikipedia.org/wiki/Newline">
14
15 <link rel="help" href="https://s9a.page/iffy">
16 <style media=(color)>
17 .iyff {filter:hue-rotate(120deg)}
18 .ffiy {filter:hue-rotate(240deg)}
19 .ffyi {filter:hue-rotate(30deg)}
20 .yiff {filter:hue-rotate(330deg)}
21 .iffy {fill:var(--iffy);stroke:var(--yffi)}
22 .yffi {fill:var(--yffi);stroke:var(--iffy)}
23 .iffy.iffy {background-color:var(--iffy);color:var(--yffi)}
24 .yffi.yffi {background-color:var(--yffi);color:var(--iffy)}
25 .iffy ::selection {color:var(--iffy);background:var(--else)}
26 .yffi ::selection {color:var(--yffi);background:var(--else)}
27 .iffy *{background-color:transparent;color:unset;--else:aquamarine}
28 .yffi *{background-color:transparent;color:unset;--else:dodgerblue}
29 *{--iffy:#528;--yffi:#ed3}
30 @media (prefers-color-scheme:dark){*{--yffi:khaki}}
31 @media (prefers-contrast:more){*{--iffy:indigo}}
32 @media (prefers-contrast:less){*{--yffi:peachpuff}}
33 </style>
34
35 <link rel="stylesheet" href="style.css">
36
37 <header class="iffy" id="hi">
38 <h1>
39 <cite>eol</cite>
40 opensource
41 newline
42 conversion
43 </h1>
44 <nav aria-label="opensource">
45 <a class="bttn yffi ffyi" href="https://github.com/ryanve/eol">github</a>
46 <a class="bttn yffi ffiy" href="https://www.npmjs.com/package/eol">npm</a>
47 </nav>
48 <p>
49 <code>eol</code> is an opensource
50 <a class="ffyi" href="https://en.wikipedia.org/wiki/Newline">newline</a>
51 conversion <code>node</code> module.
52 <code>eol</code> helps you smoothly convert <i>line endings</i>
53 in <a class="ffyi" href="https://nodejs.org">node</a> applications.
54 <code>eol</code> is written in JavaScript and supports TypeScript too.
55 The words <i>newline</i>, <i>linebreak</i>, <i>line ending</i>
56 are used interchangeably here.
57 They mark an <i>end of line</i>.
58 Feel free to play with <code>eol</code>
59 in the console on this page for learning purposes.
60 </p>
61 </header>
62
63 <section class="yffi" id="methods">
64 <h2>methods</h2>
65 <dl>
66 <dt><code>eol.auto(<var>text</var>)</code>
67 <dd>Normalize <var>text</var> to match the current operating system
68 <dd>Returns string with <i>line endings</i> normalized accordingly
69 <dt><code>eol.crlf(<var>text</var>)</code>
70 <dd>Normalize <i>line endings</i> in <var>text</var> to CRLF (Windows, DOS)
71 <dd>Returns string normalized to <q>\r\n</q> <i>line endings</i>
72 <dt><code>eol.lf(<var>text</var>)</code>
73 <dd>Normalize <i>line endings</i> in <var>text</var> to LF (Unix, OS X)
74 <dd>Returns string normalized to <q>\n</q> <i>line endings</i>
75 <dt><code>eol.cr(<var>text</var>)</code>
76 <dd>Normalize <i>line endings</i> in <var>text</var> to CR (Mac OS)
77 <dd>Returns string normalized to <q>\r</q> <i>line endings</i>
78 <dt><code>eol.dub(<var>text</var>)</code>
79 <dd>Generate normalizer that replaces <i>line endings</i> with <var>text</var>
80 <dd>Returns composed pure function like methods above
81 <dd>Normalizers are usable as glue to join arrays
82 <dt><code>eol.before(<var>text</var>)</code>
83 <dd>Add <i>linebreak</i> before <var>text</var>
84 <dd>Returns string with <i>linebreak</i> added <em>before</em> <var>text</var>
85 <dt><code>eol.after(<var>text</var>)</code>
86 <dd>Add <i>linebreak</i> after <var>text</var>
87 <dd>Returns string with <i>linebreak</i> added <em>after</em> <var>text</var>
88 <dt><code>eol.match(<var>text</var>)</code>
89 <dd>Detect or inspect <i>linebreaks</i> in <var>text</var>
90 <dd>Returns array of matched <i>linebreaks</i>
91 <dt><code>eol.split(<var>text</var>)</code>
92 <dd>Split <var>text</var> by <i>newline</i>
93 <dd>Returns array of lines
94 </dl>
95 </section>
96
97 <section class="yffi ffyi" id="samples">
98 <h2>samples</h2>
99 <h3>normalizing</h3>
100 <pre>eol.lf("hello<b>\r\n</b>world<b>\r\n</b>")<br>// "hello<b>\n</b>world<b>\n</b>"</pre>
101 <h3>remove empty lines</h3>
102 <pre>eol.split(text).filter(line => line).join(eol.lf)</pre>
103 <h3>detect or inspect</h3>
104 <pre>eol.match("hello<b>\n</b>world<b>\n</b>")<br>// ["\n","\n"]</pre>
105 <h3>coercion</h3>
106 <pre>String(eol.lf) // "\n"</pre>
107 <pre>String(eol.cr) // "\r"</pre>
108 <pre>String(eol.crlf) // "\r\n"</pre>
109 <h3>generating normalizers</h3>
110 <pre>let lflf = eol.dub("\n\n")<br>lflf("hello<b>\n</b>world<b>\n</b>")<br>// "hello<b>\n\n</b>world<b>\n\n</b>"</pre>
111 </section>
112
113 <footer class="yffi yiff" id="thankyou">
114 <h2>thank you</h2>
115 <p>
116 Thank you for being part of the opensource community.
117 Hope you enjoy using <code>eol</code>
118 </p>
119 <p>
120 <a class="ffyi" href="https://github.com/ryanve/eol">All the code is on github</a>
121 where <a class="ffyi" href="https://github.com/sponsors/ryanve">you may sponsor its creator</a>
122 if you like
123 </p>
124 <p>
125 Color here uses the <a class="ffyi" href="https://s9a.page/iffy">iffy opensource library</a>.
126 If you enjoy space <a class="ffyi" href="https://ryanve.dev/ssv">you may also enjoy ssv</a>
127 </p>
128 <p>
129 <a class="iffy" href="#hi">=p</a>
130 </p>
131 </footer>
132
133 <script src="eol.js"></script>