Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sindresorhus/normalize-newline
Normalize the newline characters in a string to `\n`
https://github.com/sindresorhus/normalize-newline
Last synced: about 1 month ago
JSON representation
Normalize the newline characters in a string to `\n`
- Host: GitHub
- URL: https://github.com/sindresorhus/normalize-newline
- Owner: sindresorhus
- License: mit
- Created: 2014-06-28T14:58:30.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2022-07-09T03:18:37.000Z (over 2 years ago)
- Last Synced: 2024-05-22T18:06:57.710Z (6 months ago)
- Language: JavaScript
- Homepage:
- Size: 17.6 KB
- Stars: 30
- Watchers: 7
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license
- Security: .github/security.md
Awesome Lists containing this project
- awesome-nodejs - normalize-newline - Normalize the newline characters in a string to `\n`. (Repository / Text/String)
README
# normalize-newline
> Normalize the [newline](https://en.wikipedia.org/wiki/Newline) characters in a string to `\n`
## Install
```
$ npm install normalize-newline
```## Usage
```js
import normalizeNewline from 'normalize-newline';normalizeNewline('foo\r\nbar\nbaz');
//=> 'foo\nbar\nbaz'normalizeNewline(Buffer.from('foo\r\nbar\nbaz')).toString();
//=> 'foo\nbar\nbaz'
```## API
### normalizeNewline(input)
#### input
Type: `string | Buffer`
Input to normalize.
## Related
- [normalize-newline-cli](https://github.com/sindresorhus/normalize-newline-cli) - CLI for this module