You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # detect-newline [![Build Status](https://travis-ci.org/sindresorhus/detect-newline.svg?branch=master)](https://travis-ci.org/sindresorhus/detect-newline)
  2. > Detect the dominant newline character of a string
  3. ## Install
  4. ```
  5. $ npm install --save detect-newline
  6. ```
  7. ## Usage
  8. ```js
  9. const detectNewline = require('detect-newline');
  10. detectNewline('foo\nbar\nbaz\r\n');
  11. //=> '\n'
  12. ```
  13. ## API
  14. ### detectNewline(input)
  15. Returns detected newline or `null` when no newline character is found.
  16. ### detectNewline.graceful(input)
  17. Returns detected newline or `\n` when no newline character is found.
  18. ## Related
  19. - [detect-newline-cli](https://github.com/sindresorhus/detect-newline-cli) - CLI for this module
  20. - [detect-indent](https://github.com/sindresorhus/detect-indent) - Detect the indentation of code
  21. ## License
  22. MIT © [Sindre Sorhus](http://sindresorhus.com)