1.0.0 • Published 7 years ago
detect-newline-at-eof v1.0.0
detect-newline-at-eof
Detect newline at end of file
detect-newline-at-eof is similar to trailing-newline but will also match \n on Windows and \r\n on macOS.
Installation
$ npm install detect-newline-at-eofUsage
const fs = require('fs')
const detectNewlineAtEof = require('detect-newline-at-eof')
const fileContents = fs.readFileSync('file.txt', 'utf8')
const newlineCharacter = detectNewlineAtEof(fileContents)
console.log(newlineCharacter)
// => \n, \r\n, or null if no newline character at the end was foundChangelog
This project follows Semantic Versioning 2.
- v1.0.0 (2018-07-20):- Add support for Node.js v6, v8, and v10
- Drop support for Node.js versions older than v6
- Drop support for io.js
 
- v0.1.0 (2015-07-18): Initial release.