[Pkg-javascript-commits] [node-ansi-styles] 01/05: New upstream version 3.2.0

Praveen Arimbrathodiyil praveen at moszumanska.debian.org
Fri Sep 8 13:19:23 UTC 2017


This is an automated email from the git hooks/post-receive script.

praveen pushed a commit to branch master
in repository node-ansi-styles.

commit 5155a02b8e4859ca443d0019b3f170ffa435dc23
Author: Pirate Praveen <praveen at debian.org>
Date:   Fri Sep 8 14:57:58 2017 +0530

    New upstream version 3.2.0
---
 .editorconfig |   2 +-
 .npmrc        |   1 +
 .travis.yml   |   2 +-
 index.js      |  46 ++++++++++++++++++++-----
 license       |  20 +++--------
 package.json  | 108 ++++++++++++++++++++++++++++------------------------------
 readme.md     |  45 +++++++++++++++++++-----
 test.js       |  18 +++++++---
 8 files changed, 147 insertions(+), 95 deletions(-)

diff --git a/.editorconfig b/.editorconfig
index 98a761d..1c6314a 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -7,6 +7,6 @@ charset = utf-8
 trim_trailing_whitespace = true
 insert_final_newline = true
 
-[{package.json,*.yml}]
+[*.yml]
 indent_style = space
 indent_size = 2
diff --git a/.npmrc b/.npmrc
new file mode 100644
index 0000000..43c97e7
--- /dev/null
+++ b/.npmrc
@@ -0,0 +1 @@
+package-lock=false
diff --git a/.travis.yml b/.travis.yml
index b18bae5..7d69d74 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,5 @@
-sudo: false
 language: node_js
 node_js:
+  - '8'
   - '6'
   - '4'
diff --git a/index.js b/index.js
index a2a7434..3d3baa6 100644
--- a/index.js
+++ b/index.js
@@ -17,6 +17,7 @@ const wrapAnsi16m = (fn, offset) => function () {
 };
 
 function assembleStyles() {
+	const codes = new Map();
 	const styles = {
 		modifier: {
 			reset: [0, 0],
@@ -38,7 +39,16 @@ function assembleStyles() {
 			magenta: [35, 39],
 			cyan: [36, 39],
 			white: [37, 39],
-			gray: [90, 39]
+			gray: [90, 39],
+
+			// Bright color
+			redBright: [91, 39],
+			greenBright: [92, 39],
+			yellowBright: [93, 39],
+			blueBright: [94, 39],
+			magentaBright: [95, 39],
+			cyanBright: [96, 39],
+			whiteBright: [97, 39]
 		},
 		bgColor: {
 			bgBlack: [40, 49],
@@ -48,30 +58,49 @@ function assembleStyles() {
 			bgBlue: [44, 49],
 			bgMagenta: [45, 49],
 			bgCyan: [46, 49],
-			bgWhite: [47, 49]
+			bgWhite: [47, 49],
+
+			// Bright color
+			bgBlackBright: [100, 49],
+			bgRedBright: [101, 49],
+			bgGreenBright: [102, 49],
+			bgYellowBright: [103, 49],
+			bgBlueBright: [104, 49],
+			bgMagentaBright: [105, 49],
+			bgCyanBright: [106, 49],
+			bgWhiteBright: [107, 49]
 		}
 	};
 
-	// fix humans
+	// Fix humans
 	styles.color.grey = styles.color.gray;
 
-	Object.keys(styles).forEach(groupName => {
+	for (const groupName of Object.keys(styles)) {
 		const group = styles[groupName];
 
-		Object.keys(group).forEach(styleName => {
+		for (const styleName of Object.keys(group)) {
 			const style = group[styleName];
 
-			styles[styleName] = group[styleName] = {
+			styles[styleName] = {
 				open: `\u001B[${style[0]}m`,
 				close: `\u001B[${style[1]}m`
 			};
-		});
+
+			group[styleName] = styles[styleName];
+
+			codes.set(style[0], style[1]);
+		}
 
 		Object.defineProperty(styles, groupName, {
 			value: group,
 			enumerable: false
 		});
-	});
+
+		Object.defineProperty(styles, 'codes', {
+			value: codes,
+			enumerable: false
+		});
+	}
 
 	const rgb2rgb = (r, g, b) => [r, g, b];
 
@@ -116,6 +145,7 @@ function assembleStyles() {
 	return styles;
 }
 
+// Make the export immutable
 Object.defineProperty(module, 'exports', {
 	enumerable: true,
 	get: assembleStyles
diff --git a/license b/license
index 654d0bf..e7af2f7 100644
--- a/license
+++ b/license
@@ -1,21 +1,9 @@
-The MIT License (MIT)
+MIT License
 
 Copyright (c) Sindre Sorhus <sindresorhus at gmail.com> (sindresorhus.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:
+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 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.
+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/package.json b/package.json
index 6f845d8..432ed81 100644
--- a/package.json
+++ b/package.json
@@ -1,58 +1,54 @@
 {
-  "name": "ansi-styles",
-  "version": "3.0.0",
-  "description": "ANSI escape codes for styling strings in the terminal",
-  "license": "MIT",
-  "repository": "chalk/ansi-styles",
-  "author": {
-    "name": "Sindre Sorhus",
-    "email": "sindresorhus at gmail.com",
-    "url": "sindresorhus.com"
-  },
-  "maintainers": [
-    "Sindre Sorhus <sindresorhus at gmail.com> (sindresorhus.com)",
-    "Joshua Boy Nicolai Appelman <joshua at jbna.nl> (jbna.nl)",
-    "Josh Junon <i.am.qix at gmail.com> (github.com/qix-)"
-  ],
-  "engines": {
-    "node": ">=4"
-  },
-  "scripts": {
-    "test": "xo && ava"
-  },
-  "files": [
-    "index.js"
-  ],
-  "keywords": [
-    "ansi",
-    "styles",
-    "color",
-    "colour",
-    "colors",
-    "terminal",
-    "console",
-    "cli",
-    "string",
-    "tty",
-    "escape",
-    "formatting",
-    "rgb",
-    "256",
-    "shell",
-    "xterm",
-    "log",
-    "logging",
-    "command-line",
-    "text"
-  ],
-  "dependencies": {
-    "color-convert": "^1.0.0"
-  },
-  "devDependencies": {
-    "ava": "*",
-    "xo": "*"
-  },
-  "xo": {
-    "esnext": true
-  }
+	"name": "ansi-styles",
+	"version": "3.2.0",
+	"description": "ANSI escape codes for styling strings in the terminal",
+	"license": "MIT",
+	"repository": "chalk/ansi-styles",
+	"author": {
+		"name": "Sindre Sorhus",
+		"email": "sindresorhus at gmail.com",
+		"url": "sindresorhus.com"
+	},
+	"engines": {
+		"node": ">=4"
+	},
+	"scripts": {
+		"test": "xo && ava"
+	},
+	"files": [
+		"index.js"
+	],
+	"keywords": [
+		"ansi",
+		"styles",
+		"color",
+		"colour",
+		"colors",
+		"terminal",
+		"console",
+		"cli",
+		"string",
+		"tty",
+		"escape",
+		"formatting",
+		"rgb",
+		"256",
+		"shell",
+		"xterm",
+		"log",
+		"logging",
+		"command-line",
+		"text"
+	],
+	"dependencies": {
+		"color-convert": "^1.9.0"
+	},
+	"devDependencies": {
+		"ava": "*",
+		"babel-polyfill": "^6.23.0",
+		"xo": "*"
+	},
+	"ava": {
+		"require": "babel-polyfill"
+	}
 }
diff --git a/readme.md b/readme.md
index c40bace..dce3687 100644
--- a/readme.md
+++ b/readme.md
@@ -10,7 +10,7 @@ You probably want the higher-level [chalk](https://github.com/chalk/chalk) modul
 ## Install
 
 ```
-$ npm install --save ansi-styles
+$ npm install ansi-styles
 ```
 
 
@@ -22,8 +22,8 @@ const style = require('ansi-styles');
 console.log(`${style.green.open}Hello world!${style.green.close}`);
 
 
-// color conversion between 16/256/truecolor
-// NOTE: if conversion goes to 16 colors or 256 colors, the original color
+// Color conversion between 16/256/truecolor
+// NOTE: If conversion goes to 16 colors or 256 colors, the original color
 //       may be degraded to fit that color palette. This means terminals
 //       that do not support 16 million colors will best-match the
 //       original color.
@@ -44,11 +44,11 @@ Each style has an `open` and `close` property.
 - `reset`
 - `bold`
 - `dim`
-- `italic` *(not widely supported)*
+- `italic` *(Not widely supported)*
 - `underline`
 - `inverse`
 - `hidden`
-- `strikethrough` *(not widely supported)*
+- `strikethrough` *(Not widely supported)*
 
 ### Colors
 
@@ -60,7 +60,14 @@ Each style has an `open` and `close` property.
 - `magenta`
 - `cyan`
 - `white`
-- `gray`
+- `gray` ("bright black")
+- `redBright`
+- `greenBright`
+- `yellowBright`
+- `blueBright`
+- `magentaBright`
+- `cyanBright`
+- `whiteBright`
 
 ### Background colors
 
@@ -72,6 +79,14 @@ Each style has an `open` and `close` property.
 - `bgMagenta`
 - `bgCyan`
 - `bgWhite`
+- `bgBlackBright`
+- `bgRedBright`
+- `bgGreenBright`
+- `bgYellowBright`
+- `bgBlueBright`
+- `bgMagentaBright`
+- `bgCyanBright`
+- `bgWhiteBright`
 
 
 ## Advanced usage
@@ -82,13 +97,21 @@ By default, you get a map of styles, but the styles are also available as groups
 - `style.color`
 - `style.bgColor`
 
-
 ###### Example
 
 ```js
 console.log(style.color.green.open);
 ```
 
+Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `style.codes`, which returns a `Map` with the open codes as keys and close codes as values.
+
+###### Example
+
+```js
+console.log(style.codes.get(36));
+//=> 39
+```
+
 
 ## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728)
 
@@ -113,6 +136,12 @@ style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color backgroun
 - [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
 
 
+## Maintainers
+
+- [Sindre Sorhus](https://github.com/sindresorhus)
+- [Josh Junon](https://github.com/qix-)
+
+
 ## License
 
-MIT © [Sindre Sorhus](https://sindresorhus.com)
+MIT
diff --git a/test.js b/test.js
index fbc1098..fcd8265 100644
--- a/test.js
+++ b/test.js
@@ -1,8 +1,8 @@
 import test from 'ava';
-import style from './';
+import style from '.';
 
-// generates the screenshot
-for (const [key, val] of Object.entries(style)) { // eslint-disable-line no-use-extend-native/no-use-extend-native
+// Generates the screenshot
+for (const [key, val] of Object.entries(style)) {
 	let code = val.open;
 
 	if (key === 'reset' || key === 'hidden' || key === 'grey') {
@@ -35,8 +35,8 @@ test('groups should not be enumerable', t => {
 });
 
 test('don\'t pollute other objects', t => {
-	const obj1 = require('./');
-	const obj2 = require('./');
+	const obj1 = require('.');
+	const obj2 = require('.');
 
 	obj1.foo = true;
 	t.not(obj1.foo, obj2.foo);
@@ -82,3 +82,11 @@ test('16/256/16m color close escapes', t => {
 	t.is(style.color.close, '\u001B[39m');
 	t.is(style.bgColor.close, '\u001B[49m');
 });
+
+test('export raw ANSI escape codes', t => {
+	t.is(style.codes.get(0), 0);
+	t.is(style.codes.get(1), 22);
+	t.is(style.codes.get(91), 39);
+	t.is(style.codes.get(40), 49);
+	t.is(style.codes.get(100), 49);
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-ansi-styles.git



More information about the Pkg-javascript-commits mailing list