Skip to content

Detect the dominant newline character of a string

License

Notifications You must be signed in to change notification settings

MaximDevoir/detect-newline

 
 

Repository files navigation

detect-newline Build Status

Detect the dominant newline character of a string

Install

$ npm install detect-newline

Usage

const detectNewline = require('detect-newline');

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

API

detectNewline(string)

Returns the detected newline or undefined when no newline character is found.

detectNewline.graceful(string)

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

Related

License

MIT © Sindre Sorhus

About

Detect the dominant newline character of a string

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 79.4%
  • TypeScript 20.6%