Skip to content

Commit 166a0d5

Browse files
committedMay 31, 2019
Require Node.js 8
1 parent f115fca commit 166a0d5

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed
 

‎.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: node_js
22
node_js:
3+
- '12'
34
- '10'
45
- '8'
5-
- '6'

‎index.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
'use strict';
22

3-
module.exports = options => {
4-
options = Object.assign({
5-
onlyFirst: false
6-
}, options);
7-
3+
module.exports = ({onlyFirst = false} = {}) => {
84
const pattern = [
95
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
106
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
117
].join('|');
128

13-
return new RegExp(pattern, options.onlyFirst ? undefined : 'g');
9+
return new RegExp(pattern, onlyFirst ? undefined : 'g');
1410
};

‎package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"url": "sindresorhus.com"
1111
},
1212
"engines": {
13-
"node": ">=6"
13+
"node": ">=8"
1414
},
1515
"scripts": {
1616
"test": "xo && ava",
@@ -47,7 +47,7 @@
4747
"pattern"
4848
],
4949
"devDependencies": {
50-
"ava": "^0.25.0",
51-
"xo": "^0.23.0"
50+
"ava": "^1.4.1",
51+
"xo": "^0.24.0"
5252
}
5353
}

‎test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import test from 'ava';
22
import ansiCodes from './fixtures/ansi-codes';
33
import ansiRegex from '.';
44

5-
const consumptionChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+1234567890-=[]{};\':"./>?,<\\|';
5+
const consumptionCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+1234567890-=[]{};\':"./>?,<\\|';
66

77
// Testing against codes found at: http://ascii-table.com/ansi-escape-sequences-vt-100.php
88
test('match ansi code in a string', t => {
@@ -67,7 +67,7 @@ for (const codeSet of Object.keys(ansiCodes)) {
6767
const skipText = skip ? '[SKIP] ' : '';
6868
const ecode = `\u001B${code}`;
6969

70-
test(`${skipText}${code}${codeInfo[0]}`, t => {
70+
test(`${codeSet} - ${skipText}${code}${codeInfo[0]}`, t => {
7171
if (skip) {
7272
t.pass();
7373
return;
@@ -79,13 +79,13 @@ for (const codeSet of Object.keys(ansiCodes)) {
7979
t.is(string.replace(ansiRegex(), ''), 'hello');
8080
});
8181

82-
test(`${skipText}${code} should not overconsume`, t => {
82+
test(`${codeSet} - ${skipText}${code} should not overconsume`, t => {
8383
if (skip) {
8484
t.pass();
8585
return;
8686
}
8787

88-
for (const c of consumptionChars) {
88+
for (const c of consumptionCharacters) {
8989
const string = ecode + c;
9090
t.regex(string, ansiRegex());
9191
t.is(string.match(ansiRegex())[0], ecode);

0 commit comments

Comments
 (0)
Please sign in to comment.