[Pkg-javascript-commits] [node-ansicolors] 01/06: Import Upstream version 0.3.2
Shanavas M
shanavas-guest at moszumanska.debian.org
Sun Mar 19 07:07:35 UTC 2017
This is an automated email from the git hooks/post-receive script.
shanavas-guest pushed a commit to branch master
in repository node-ansicolors.
commit bea8f192704f0275620fafc3a0c12ac04f9069ed
Author: Shanavas M <shanavas at disroot.org>
Date: Sun Mar 19 06:01:09 2017 +0000
Import Upstream version 0.3.2
---
.gitignore | 15 ++++++++++++
.npmignore | 2 ++
.travis.yml | 4 +++
LICENSE | 23 ++++++++++++++++++
README.md | 62 +++++++++++++++++++++++++++++++++++++++++++++++
ansicolors.js | 65 +++++++++++++++++++++++++++++++++++++++++++++++++
package.json | 23 ++++++++++++++++++
test/ansicolors.js | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 265 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a72b52e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,15 @@
+lib-cov
+*.seed
+*.log
+*.csv
+*.dat
+*.out
+*.pid
+*.gz
+
+pids
+logs
+results
+
+npm-debug.log
+node_modules
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 0000000..2cf6a27
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,2 @@
+.npmignore
+.travis.yml
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..895dbd3
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - 0.6
+ - 0.8
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..41702c5
--- /dev/null
+++ b/LICENSE
@@ -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.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..f3e9d07
--- /dev/null
+++ b/README.md
@@ -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).
diff --git a/ansicolors.js b/ansicolors.js
new file mode 100644
index 0000000..16b2586
--- /dev/null
+++ b/ansicolors.js
@@ -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;
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..cda0c75
--- /dev/null
+++ b/package.json
@@ -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 at gmx.de> (thlorenz.com)",
+ "license": "MIT",
+ "readmeFilename": "README.md",
+ "gitHead": "858847ca28e8b360d9b70eee0592700fa2ab087d"
+}
diff --git a/test/ansicolors.js b/test/ansicolors.js
new file mode 100644
index 0000000..4945393
--- /dev/null
+++ b/test/ansicolors.js
@@ -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');
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-ansicolors.git
More information about the Pkg-javascript-commits
mailing list