summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/slice-ansi
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/node_modules/slice-ansi')
-rwxr-xr-xtools/node_modules/eslint/node_modules/slice-ansi/index.js88
-rw-r--r--tools/node_modules/eslint/node_modules/slice-ansi/license9
-rw-r--r--tools/node_modules/eslint/node_modules/slice-ansi/package.json85
-rwxr-xr-xtools/node_modules/eslint/node_modules/slice-ansi/readme.md64
4 files changed, 246 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/node_modules/slice-ansi/index.js b/tools/node_modules/eslint/node_modules/slice-ansi/index.js
new file mode 100755
index 0000000000..634ee9c7be
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/slice-ansi/index.js
@@ -0,0 +1,88 @@
+'use strict';
+const isFullwidthCodePoint = require('is-fullwidth-code-point');
+
+const ESCAPES = [
+ '\u001B',
+ '\u009B'
+];
+
+const END_CODE = 39;
+const ASTRAL_REGEX = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
+
+const ESCAPE_CODES = new Map([
+ [0, 0],
+ [1, 22],
+ [2, 22],
+ [3, 23],
+ [4, 24],
+ [7, 27],
+ [8, 28],
+ [9, 29],
+ [30, 39],
+ [31, 39],
+ [32, 39],
+ [33, 39],
+ [34, 39],
+ [35, 39],
+ [36, 39],
+ [37, 39],
+ [90, 39],
+ [40, 49],
+ [41, 49],
+ [42, 49],
+ [43, 49],
+ [44, 49],
+ [45, 49],
+ [46, 49],
+ [47, 49]
+]);
+
+const wrapAnsi = code => `${ESCAPES[0]}[${code}m`;
+
+module.exports = (str, begin, end) => {
+ const arr = Array.from(str.normalize());
+
+ end = typeof end === 'number' ? end : arr.length;
+
+ let insideEscape = false;
+ let escapeCode;
+ let visible = 0;
+ let output = '';
+
+ for (const item of arr.entries()) {
+ const i = item[0];
+ const x = item[1];
+
+ let leftEscape = false;
+
+ if (ESCAPES.indexOf(x) !== -1) {
+ insideEscape = true;
+ const code = /\d[^m]*/.exec(str.slice(i, i + 4));
+ escapeCode = code === END_CODE ? null : code;
+ } else if (insideEscape && x === 'm') {
+ insideEscape = false;
+ leftEscape = true;
+ }
+
+ if (!insideEscape && !leftEscape) {
+ ++visible;
+ }
+
+ if (!ASTRAL_REGEX.test(x) && isFullwidthCodePoint(x.codePointAt())) {
+ ++visible;
+ }
+
+ if (visible > begin && visible <= end) {
+ output += x;
+ } else if (visible === begin && !insideEscape && escapeCode !== undefined && escapeCode !== END_CODE) {
+ output += wrapAnsi(escapeCode);
+ } else if (visible >= end) {
+ if (escapeCode !== undefined) {
+ output += wrapAnsi(ESCAPE_CODES.get(parseInt(escapeCode, 10)) || END_CODE);
+ }
+ break;
+ }
+ }
+
+ return output;
+};
diff --git a/tools/node_modules/eslint/node_modules/slice-ansi/license b/tools/node_modules/eslint/node_modules/slice-ansi/license
new file mode 100644
index 0000000000..4d726339ce
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/slice-ansi/license
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) DC <threedeecee@gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/tools/node_modules/eslint/node_modules/slice-ansi/package.json b/tools/node_modules/eslint/node_modules/slice-ansi/package.json
new file mode 100644
index 0000000000..be6b2e4bc5
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/slice-ansi/package.json
@@ -0,0 +1,85 @@
+{
+ "_from": "slice-ansi@1.0.0",
+ "_id": "slice-ansi@1.0.0",
+ "_inBundle": false,
+ "_integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==",
+ "_location": "/eslint/slice-ansi",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "version",
+ "registry": true,
+ "raw": "slice-ansi@1.0.0",
+ "name": "slice-ansi",
+ "escapedName": "slice-ansi",
+ "rawSpec": "1.0.0",
+ "saveSpec": null,
+ "fetchSpec": "1.0.0"
+ },
+ "_requiredBy": [
+ "/eslint/table"
+ ],
+ "_resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz",
+ "_shasum": "044f1a49d8842ff307aad6b505ed178bd950134d",
+ "_spec": "slice-ansi@1.0.0",
+ "_where": "/Users/cjihrig/iojs/node/tools/eslint-tmp/node_modules/eslint/node_modules/table",
+ "author": {
+ "name": "David Caccavella",
+ "email": "threedeecee@gmail.com"
+ },
+ "bugs": {
+ "url": "https://github.com/chalk/slice-ansi/issues"
+ },
+ "bundleDependencies": false,
+ "dependencies": {
+ "is-fullwidth-code-point": "^2.0.0"
+ },
+ "deprecated": false,
+ "description": "Slice a string with ANSI escape codes",
+ "devDependencies": {
+ "ava": "*",
+ "chalk": "^2.0.1",
+ "random-item": "^1.0.0",
+ "strip-ansi": "^4.0.0",
+ "xo": "*"
+ },
+ "engines": {
+ "node": ">=4"
+ },
+ "files": [
+ "index.js"
+ ],
+ "homepage": "https://github.com/chalk/slice-ansi#readme",
+ "keywords": [
+ "slice",
+ "string",
+ "ansi",
+ "styles",
+ "color",
+ "colour",
+ "colors",
+ "terminal",
+ "console",
+ "cli",
+ "tty",
+ "escape",
+ "formatting",
+ "rgb",
+ "256",
+ "shell",
+ "xterm",
+ "log",
+ "logging",
+ "command-line",
+ "text"
+ ],
+ "license": "MIT",
+ "name": "slice-ansi",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/chalk/slice-ansi.git"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "version": "1.0.0"
+}
diff --git a/tools/node_modules/eslint/node_modules/slice-ansi/readme.md b/tools/node_modules/eslint/node_modules/slice-ansi/readme.md
new file mode 100755
index 0000000000..628eed2e50
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/slice-ansi/readme.md
@@ -0,0 +1,64 @@
+# slice-ansi [![Build Status](https://travis-ci.org/chalk/slice-ansi.svg?branch=master)](https://travis-ci.org/chalk/slice-ansi) [![XO: Linted](https://img.shields.io/badge/xo-linted-blue.svg)](https://github.com/sindresorhus/xo)
+
+> Slice a string with [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)
+
+
+## Install
+
+```
+$ npm install slice-ansi
+```
+
+
+## Usage
+
+```js
+const chalk = require('chalk');
+const sliceAnsi = require('slice-ansi');
+
+const input = 'The quick brown ' + chalk.red('fox jumped over ') +
+ 'the lazy ' + chalk.green('dog and then ran away with the unicorn.');
+
+console.log(sliceAnsi(input, 20, 30));
+```
+
+
+## API
+
+### sliceAnsi(input, beginSlice, [endSlice])
+
+#### input
+
+Type: `string`
+
+String with ANSI escape codes. Like one styled by [`chalk`](https://github.com/chalk/chalk).
+
+#### beginSlice
+
+Type: `number`
+
+Zero-based index at which to begin the slice.
+
+#### endSlice
+
+Type: `number`
+
+Zero-based index at which to end the slice.
+
+
+## Related
+
+- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
+- [cli-truncate](https://github.com/sindresorhus/cli-truncate) - Truncate a string to a specific width in the terminal
+- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
+
+
+## Maintainers
+
+- [Sindre Sorhus](https://github.com/sindresorhus)
+- [Josh Junon](https://github.com/qix-)
+
+
+## License
+
+MIT