Skip to content

Commit

Permalink
Require Node.js 6
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed May 29, 2018
1 parent c0357e6 commit c7ef178
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 62 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
@@ -1,2 +1 @@
* text=auto
*.js text eol=lf
* text=auto eol=lf
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,5 +1,5 @@
language: node_js
node_js:
- '10'
- '8'
- '6'
- '4'
9 changes: 3 additions & 6 deletions index.js
Expand Up @@ -13,7 +13,7 @@ const END_CODE = 39;
const wrapAnsi = code => `${ESCAPES[0]}[${code}m`;

module.exports = (str, begin, end) => {
const arr = Array.from(str.normalize());
const arr = [...str.normalize()];

end = typeof end === 'number' ? end : arr.length;

Expand All @@ -22,13 +22,10 @@ module.exports = (str, begin, end) => {
let visible = 0;
let output = '';

for (const item of arr.entries()) {
const i = item[0];
const x = item[1];

for (const [i, x] of arr.entries()) {
let leftEscape = false;

if (ESCAPES.indexOf(x) !== -1) {
if (ESCAPES.includes(x)) {
insideEscape = true;
const code = /\d[^m]*/.exec(str.slice(i, i + 4));
escapeCode = code === END_CODE ? null : code;
Expand Down
102 changes: 49 additions & 53 deletions package.json
@@ -1,55 +1,51 @@
{
"name": "slice-ansi",
"version": "1.0.0",
"description": "Slice a string with ANSI escape codes",
"license": "MIT",
"repository": "chalk/slice-ansi",
"author": {
"name": "David Caccavella",
"email": "threedeecee@gmail.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"slice",
"string",
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"dependencies": {
"ansi-styles": "^3.2.0",
"astral-regex": "^1.0.0",
"is-fullwidth-code-point": "^2.0.0"
},
"devDependencies": {
"ava": "*",
"chalk": "^2.0.1",
"random-item": "^1.0.0",
"strip-ansi": "^4.0.0",
"xo": "*"
}
"name": "slice-ansi",
"version": "1.0.0",
"description": "Slice a string with ANSI escape codes",
"license": "MIT",
"repository": "chalk/slice-ansi",
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"slice",
"string",
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"dependencies": {
"ansi-styles": "^3.2.0",
"astral-regex": "^1.0.0",
"is-fullwidth-code-point": "^2.0.0"
},
"devDependencies": {
"ava": "*",
"chalk": "^2.0.1",
"random-item": "^1.0.0",
"strip-ansi": "^4.0.0",
"xo": "*"
}
}

0 comments on commit c7ef178

Please sign in to comment.