diff --git a/.editorconfig b/.editorconfig index 8f9d77e..98a761d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,6 +10,3 @@ insert_final_newline = true [{package.json,*.yml}] indent_style = space indent_size = 2 - -[*.md] -trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes index 176a458..391f0a4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ * text=auto +*.js text eol=lf diff --git a/.travis.yml b/.travis.yml index 2a2f1c6..97519af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: node_js node_js: - - 'stable' - - '0.12' - - '0.10' + - '6' + - '4' diff --git a/index.js b/index.js index da31efd..f22c313 100644 --- a/index.js +++ b/index.js @@ -1,13 +1,4 @@ 'use strict'; - -var fn = module.exports = function (x) { - return fn.end(fn.start(x)); -}; - -fn.start = function (x) { - return x.replace(/^[\r\n]+/, ''); -}; - -fn.end = function (x) { - return x.replace(/[\r\n]+$/, ''); -}; +module.exports = x => x.replace(/^[\r\n]+/, '').replace(/[\r\n]+$/, ''); +module.exports.start = x => x.replace(/^[\r\n]+/, ''); +module.exports.end = x => x.replace(/[\r\n]+$/, ''); diff --git a/package.json b/package.json index c0bca90..ede37d3 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "url": "sindresorhus.com" }, "engines": { - "node": ">=0.10.0" + "node": ">=4" }, "scripts": { "test": "xo && ava" diff --git a/readme.md b/readme.md index fedb3ca..2737ea2 100644 --- a/readme.md +++ b/readme.md @@ -13,7 +13,7 @@ $ npm install --save trim-newlines ## Usage ```js -var trimNewlines = require('trim-newlines'); +const trimNewlines = require('trim-newlines'); trimNewlines('\nunicorn\r\n'); //=> 'unicorn' @@ -43,4 +43,4 @@ Trim from the end of a string. ## License -MIT © [Sindre Sorhus](http://sindresorhus.com) +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/test.js b/test.js index fcef2bf..fe65257 100644 --- a/test.js +++ b/test.js @@ -1,25 +1,25 @@ import test from 'ava'; -import fn from './'; +import m from '.'; test('main', t => { - t.is(fn('\nx\n'), 'x'); - t.is(fn('\n\n\nx\n\n\n'), 'x'); - t.is(fn('\r\nx\r\n'), 'x'); - t.is(fn('\n\r\n\nx\n\r\n\n'), 'x'); + t.is(m('\nx\n'), 'x'); + t.is(m('\n\n\nx\n\n\n'), 'x'); + t.is(m('\r\nx\r\n'), 'x'); + t.is(m('\n\r\n\nx\n\r\n\n'), 'x'); }); test('start', t => { - t.is(fn.start('\nx'), 'x'); - t.is(fn.start('\r\nx'), 'x'); - t.is(fn.start('\n\n\n\nx'), 'x'); - t.is(fn.start('\n\n\r\n\nx'), 'x'); - t.is(fn.start('x\n\n\r\n\n'), 'x\n\n\r\n\n'); + t.is(m.start('\nx'), 'x'); + t.is(m.start('\r\nx'), 'x'); + t.is(m.start('\n\n\n\nx'), 'x'); + t.is(m.start('\n\n\r\n\nx'), 'x'); + t.is(m.start('x\n\n\r\n\n'), 'x\n\n\r\n\n'); }); test('end', t => { - t.is(fn.end('x\n'), 'x'); - t.is(fn.end('x\r\n'), 'x'); - t.is(fn.end('x\n\n\n\n'), 'x'); - t.is(fn.end('x\n\n\r\n\n'), 'x'); - t.is(fn.end('\n\n\r\n\nx'), '\n\n\r\n\nx'); + t.is(m.end('x\n'), 'x'); + t.is(m.end('x\r\n'), 'x'); + t.is(m.end('x\n\n\n\n'), 'x'); + t.is(m.end('x\n\n\r\n\n'), 'x'); + t.is(m.end('\n\n\r\n\nx'), '\n\n\r\n\nx'); });