Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

normalize-newline

sindresorhus166kMIT4.1.0TypeScript support: included

Normalize the newline characters in a string to \n

newline, linebreak, line, lf, crlf, eol, linefeed, character, char, normalize, convert, replace

readme

normalize-newline

Normalize the newline characters in a string to \n

Install

$ npm install normalize-newline

Usage

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.