Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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`

Awesome Lists containing this project

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