detect-newline
Detect the dominant newline character of a string
Last updated 6 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm
$ cnpm install detect-newline 
SYNC missed versions from official npm registry.

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(unknown)

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

Related

License

MIT © Sindre Sorhus

Current Tags

  • 4.0.0                                ...           latest (4 years ago)

4 Versions

  • 4.0.0                                ...           4 years ago
  • 1.0.3                                ...           11 years ago
  • 3.1.0                                ...           6 years ago
  • 2.1.0                                ...           10 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (3)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org