|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
923 bytes
|
| Line | |
|---|
| 1 | # strip-final-newline [](https://travis-ci.com/sindresorhus/strip-final-newline)
|
|---|
| 2 |
|
|---|
| 3 | > Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from a string/buffer
|
|---|
| 4 |
|
|---|
| 5 | Can be useful when parsing the output of, for example, `ChildProcess#execFile`, as [binaries usually output a newline at the end](https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline). Normally, you would use `stdout.trim()`, but that would also remove newlines at the start and whitespace.
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 | ## Install
|
|---|
| 9 |
|
|---|
| 10 | ```
|
|---|
| 11 | $ npm install strip-final-newline
|
|---|
| 12 | ```
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 | ## Usage
|
|---|
| 16 |
|
|---|
| 17 | ```js
|
|---|
| 18 | const stripFinalNewline = require('strip-final-newline');
|
|---|
| 19 |
|
|---|
| 20 | stripFinalNewline('foo\nbar\n\n');
|
|---|
| 21 | //=> 'foo\nbar\n'
|
|---|
| 22 |
|
|---|
| 23 | stripFinalNewline(Buffer.from('foo\nbar\n\n')).toString();
|
|---|
| 24 | //=> 'foo\nbar\n'
|
|---|
| 25 | ```
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 | ## License
|
|---|
| 29 |
|
|---|
| 30 | MIT © [Sindre Sorhus](https://sindresorhus.com)
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.