Installing dependencies.

This commit is contained in:
2025-11-11 06:53:11 -05:00
parent 2c36c04da6
commit 0d2fea3c88
14371 changed files with 2770923 additions and 25 deletions
+23
View File
@@ -0,0 +1,23 @@
Copyright 2013 Thorsten Lorenz.
All rights reserved.
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.
+62
View File
@@ -0,0 +1,62 @@
# ansicolors [![build status](https://secure.travis-ci.org/thlorenz/ansicolors.png)](http://next.travis-ci.org/thlorenz/ansicolors)
Functions that surround a string with ansicolor codes so it prints in color.
In case you need styles, like `bold`, have a look at [ansistyles](https://github.com/thlorenz/ansistyles).
## Installation
npm install ansicolors
## Usage
```js
var colors = require('ansicolors');
// foreground colors
var redHerring = colors.red('herring');
var blueMoon = colors.blue('moon');
var brighBlueMoon = colors.brightBlue('moon');
console.log(redHerring); // this will print 'herring' in red
console.log(blueMoon); // this 'moon' in blue
console.log(brightBlueMoon); // I think you got the idea
// background colors
console.log(colors.bgYellow('printed on yellow background'));
console.log(colors.bgBrightBlue('printed on bright blue background'));
// mixing background and foreground colors
// below two lines have same result (order in which bg and fg are combined doesn't matter)
console.log(colors.bgYellow(colors.blue('printed on yellow background in blue')));
console.log(colors.blue(colors.bgYellow('printed on yellow background in blue')));
```
## Advanced API
**ansicolors** allows you to access opening and closing escape sequences separately.
```js
var colors = require('ansicolors');
function inspect(obj, depth) {
return require('util').inspect(obj, false, depth || 5, true);
}
console.log('open blue', inspect(colors.open.blue));
console.log('close bgBlack', inspect(colors.close.bgBlack));
// => open blue '\u001b[34m'
// close bgBlack '\u001b[49m'
```
## Tests
Look at the [tests](https://github.com/thlorenz/ansicolors/blob/master/test/ansicolors.js) to see more examples and/or run them via:
npm explore ansicolors && npm test
## Alternatives
**ansicolors** tries to meet simple use cases with a very simple API. However, if you need a more powerful ansi formatting tool,
I'd suggest to look at the [features](https://github.com/TooTallNate/ansi.js#features) of the [ansi module](https://github.com/TooTallNate/ansi.js).
+65
View File
@@ -0,0 +1,65 @@
// ColorCodes explained: http://www.termsys.demon.co.uk/vtansi.htm
'use strict';
var colorNums = {
white : 37
, black : 30
, blue : 34
, cyan : 36
, green : 32
, magenta : 35
, red : 31
, yellow : 33
, brightBlack : 90
, brightRed : 91
, brightGreen : 92
, brightYellow : 93
, brightBlue : 94
, brightMagenta : 95
, brightCyan : 96
, brightWhite : 97
}
, backgroundColorNums = {
bgBlack : 40
, bgRed : 41
, bgGreen : 42
, bgYellow : 43
, bgBlue : 44
, bgMagenta : 45
, bgCyan : 46
, bgWhite : 47
, bgBrightBlack : 100
, bgBrightRed : 101
, bgBrightGreen : 102
, bgBrightYellow : 103
, bgBrightBlue : 104
, bgBrightMagenta : 105
, bgBrightCyan : 106
, bgBrightWhite : 107
}
, open = {}
, close = {}
, colors = {}
;
Object.keys(colorNums).forEach(function (k) {
var o = open[k] = '\u001b[' + colorNums[k] + 'm';
var c = close[k] = '\u001b[39m';
colors[k] = function (s) {
return o + s + c;
};
});
Object.keys(backgroundColorNums).forEach(function (k) {
var o = open[k] = '\u001b[' + backgroundColorNums[k] + 'm';
var c = close[k] = '\u001b[49m';
colors[k] = function (s) {
return o + s + c;
};
});
module.exports = colors;
colors.open = open;
colors.close = close;
+23
View File
@@ -0,0 +1,23 @@
{
"name": "ansicolors",
"version": "0.3.2",
"description": "Functions that surround a string with ansicolor codes so it prints in color.",
"main": "ansicolors.js",
"scripts": {
"test": "node test/*.js"
},
"repository": {
"type": "git",
"url": "git://github.com/thlorenz/ansicolors.git"
},
"keywords": [
"ansi",
"colors",
"highlight",
"string"
],
"author": "Thorsten Lorenz <thlorenz@gmx.de> (thlorenz.com)",
"license": "MIT",
"readmeFilename": "README.md",
"gitHead": "858847ca28e8b360d9b70eee0592700fa2ab087d"
}
+71
View File
@@ -0,0 +1,71 @@
'use strict';
var assert = require('assert')
, colors = require('..')
, open = colors.open
, close = colors.close
console.log('Foreground colors ..');
assert.equal(colors.white('printed in white'), '\u001b[37mprinted in white\u001b[39m');
assert.equal(colors.black('printed in black'), '\u001b[30mprinted in black\u001b[39m');
assert.equal(colors.brightBlack('printed in bright black'), '\u001b[90mprinted in bright black\u001b[39m');
assert.equal(colors.green('printed in green'), '\u001b[32mprinted in green\u001b[39m');
assert.equal(colors.brightGreen('printed in bright green'), '\u001b[92mprinted in bright green\u001b[39m');
assert.equal(colors.red('printed in red'), '\u001b[31mprinted in red\u001b[39m');
assert.equal(colors.brightRed('printed in bright red'), '\u001b[91mprinted in bright red\u001b[39m');
console.log('OK');
console.log('Background colors ..');
assert.equal(
colors.bgBlack('printed with black background')
, '\u001b[40mprinted with black background\u001b[49m'
);
assert.equal(
colors.bgYellow('printed with yellow background')
, '\u001b[43mprinted with yellow background\u001b[49m'
);
assert.equal(
colors.bgBrightYellow('printed with bright yellow background')
, '\u001b[103mprinted with bright yellow background\u001b[49m'
);
assert.equal(
colors.bgWhite('printed with white background')
, '\u001b[47mprinted with white background\u001b[49m'
);
console.log('OK');
console.log('Mixing background and foreground colors ..');
assert.equal(
colors.blue(colors.bgYellow('printed in blue with yellow background'))
, '\u001b[34m\u001b[43mprinted in blue with yellow background\u001b[49m\u001b[39m'
);
assert.equal(
colors.bgYellow(colors.blue('printed in blue with yellow background again'))
, '\u001b[43m\u001b[34mprinted in blue with yellow background again\u001b[39m\u001b[49m'
);
console.log('OK');
console.log('Open ...');
assert.equal(open.black, '\u001b[30m');
assert.equal(open.bgYellow, '\u001b[43m');
console.log('OK');
console.log('Close ...');
assert.equal(close.black, '\u001b[39m');
assert.equal(close.bgYellow, '\u001b[49m');
console.log('OK');