Skip to content

sindresorhus/detect-newline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Sep 22, 2023
78057f2 · Sep 22, 2023

History

39 Commits
Jul 8, 2022
Apr 11, 2019
Apr 11, 2019
Apr 11, 2019
Apr 11, 2019
Sep 22, 2023
Oct 14, 2021
Oct 14, 2021
Oct 14, 2021
Sep 22, 2023
Sep 22, 2023
Oct 14, 2021

Repository files navigation

detect-newline

Detect the dominant newline character of a string

Install

npm install detect-newline

Usage

import {detectNewline} from 'detect-newline';

detectNewline('foo\nbar\nbaz\r\n');
//=> '\n'

API

detectNewline(string)

Returns the detected newline or undefined when no newline character is found or \n when no dominant newline is present.

detectNewlineGraceful(unknown)

Returns the detected newline or \n when no newline character is found, no dominant newline is present, or the input is not a string.

Related