mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 05:13:33 -06:00
Initial commit
This commit is contained in:
80
node_modules/slice-ansi/index.js
generated
vendored
Executable file
80
node_modules/slice-ansi/index.js
generated
vendored
Executable file
@@ -0,0 +1,80 @@
|
||||
'use strict';
|
||||
|
||||
var ESCAPES = [
|
||||
'\u001b',
|
||||
'\u009b'
|
||||
];
|
||||
|
||||
var END_CODE = 39;
|
||||
|
||||
var ESCAPE_CODES = {
|
||||
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
|
||||
};
|
||||
|
||||
function wrapAnsi(code) {
|
||||
return ESCAPES[0] + '[' + code + 'm';
|
||||
}
|
||||
|
||||
module.exports = function (str, begin, end) {
|
||||
end = end || str.length;
|
||||
var insideEscape = false;
|
||||
var escapeCode;
|
||||
var visible = 0;
|
||||
var output = '';
|
||||
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
var leftEscape = false;
|
||||
var x = str[i];
|
||||
|
||||
if (ESCAPES.indexOf(x) !== -1) {
|
||||
insideEscape = true;
|
||||
var code = /[0-9][^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 (visible > begin && visible <= end) {
|
||||
output += x;
|
||||
} else if (visible === begin && escapeCode !== undefined && escapeCode !== END_CODE) {
|
||||
output += wrapAnsi(escapeCode);
|
||||
} else if (visible >= end) {
|
||||
if (escapeCode !== undefined) {
|
||||
output += wrapAnsi(ESCAPE_CODES[escapeCode] || END_CODE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
|
22
node_modules/slice-ansi/license
generated
vendored
Executable file
22
node_modules/slice-ansi/license
generated
vendored
Executable file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2015 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.
|
105
node_modules/slice-ansi/package.json
generated
vendored
Normal file
105
node_modules/slice-ansi/package.json
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"slice-ansi@0.0.4",
|
||||
"/Users/pmarsceill/_projects/just-the-docs/node_modules/table"
|
||||
]
|
||||
],
|
||||
"_from": "slice-ansi@0.0.4",
|
||||
"_id": "slice-ansi@0.0.4",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/slice-ansi",
|
||||
"_nodeVersion": "3.2.0",
|
||||
"_npmUser": {
|
||||
"email": "threedeecee@gmail.com",
|
||||
"name": "dthree"
|
||||
},
|
||||
"_npmVersion": "2.13.3",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "slice-ansi",
|
||||
"raw": "slice-ansi@0.0.4",
|
||||
"rawSpec": "0.0.4",
|
||||
"scope": null,
|
||||
"spec": "0.0.4",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/table"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz",
|
||||
"_shasum": "edbf8903f66f7ce2f8eafd6ceed65e264c831b35",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "slice-ansi@0.0.4",
|
||||
"_where": "/Users/pmarsceill/_projects/just-the-docs/node_modules/table",
|
||||
"author": {
|
||||
"email": "threedeecee@gmail.com",
|
||||
"name": "David Caccavella"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/chalk/slice-ansi/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Slice a string with ANSI escape codes",
|
||||
"devDependencies": {
|
||||
"ava": "^0.2.0",
|
||||
"chalk": "^1.1.1",
|
||||
"strip-ansi": "^3.0.0",
|
||||
"xo": "*"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "edbf8903f66f7ce2f8eafd6ceed65e264c831b35",
|
||||
"tarball": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"gitHead": "8670277262281964b13f051d51b2e24bcfda8a66",
|
||||
"homepage": "https://github.com/chalk/slice-ansi#readme",
|
||||
"keywords": [
|
||||
"256",
|
||||
"ansi",
|
||||
"cli",
|
||||
"color",
|
||||
"colors",
|
||||
"colour",
|
||||
"command-line",
|
||||
"console",
|
||||
"escape",
|
||||
"formatting",
|
||||
"log",
|
||||
"logging",
|
||||
"rgb",
|
||||
"shell",
|
||||
"slice",
|
||||
"string",
|
||||
"styles",
|
||||
"terminal",
|
||||
"text",
|
||||
"tty",
|
||||
"xterm"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "dthree",
|
||||
"email": "threedeecee@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "slice-ansi",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/chalk/slice-ansi.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test.js && xo"
|
||||
},
|
||||
"version": "0.0.4"
|
||||
}
|
56
node_modules/slice-ansi/readme.md
generated
vendored
Executable file
56
node_modules/slice-ansi/readme.md
generated
vendored
Executable file
@@ -0,0 +1,56 @@
|
||||
# slice-ansi
|
||||
|
||||
[](https://travis-ci.org/vorpaljs/slice-ansi)
|
||||
[](https://github.com/sindresorhus/xo)
|
||||
|
||||
> Slice a string with [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save slice-ansi
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var chalk = require('chalk');
|
||||
var sliceAnsi = require('slice-ansi');
|
||||
|
||||
var 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`
|
||||
|
||||
The zero-based index at which to begin the slice.
|
||||
|
||||
#### endSlice
|
||||
|
||||
Type: `number`
|
||||
|
||||
Optional. The zero-based index at which to end the slice.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [David Caccavella](https://githbu.com/dthree)
|
Reference in New Issue
Block a user