Skip to content

Commit

Permalink
ES2015ify and require Node.js 4
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 22, 2017
1 parent 37a075d commit 152c19f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 36 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ insert_final_newline = true
[{package.json,*.yml}]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* text=auto
*.js text eol=lf
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
language: node_js
node_js:
- 'stable'
- '0.12'
- '0.10'
- '6'
- '4'
15 changes: 3 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
@@ -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]+$/, '');
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -43,4 +43,4 @@ Trim from the end of a string.

## License

MIT © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](https://sindresorhus.com)
30 changes: 15 additions & 15 deletions test.js
Original file line number Diff line number Diff line change
@@ -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');
});

0 comments on commit 152c19f

Please sign in to comment.