Socket
Socket
Sign inDemoInstall

cli-color

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-color - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

examples/art.js

35

bare.js

@@ -9,6 +9,8 @@ 'use strict';

, setPrototypeOf = require('es5-ext/object/set-prototype-of')
, includes = require('es5-ext/string/#/contains')
, memoize = require('memoizee')
, memoizeMethods = require('memoizee/methods')
, sgr = require('./lib/sgr')
, mods = sgr.mods
, join = Array.prototype.join, defineProperty = Object.defineProperty

@@ -19,25 +21,2 @@ , max = Math.max, min = Math.min

var mods = assign({
// Style
bold: { _bold: [1, 22] },
italic: { _italic: [3, 23] },
underline: { _underline: [4, 24] },
blink: { _blink: [5, 25] },
inverse: { _inverse: [7, 27] },
strike: { _strike: [9, 29] }
// Color
}, ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']
.reduce(function (obj, color, index) {
// foreground
obj[color] = { _fg: [30 + index, 39] };
obj[color + 'Bright'] = { _fg: [90 + index, 39] };
// background
obj['bg' + color[0].toUpperCase() + color.slice(1)] = { _bg: [40 + index, 49] };
obj['bg' + color[0].toUpperCase() + color.slice(1) + 'Bright'] = { _bg: [100 + index, 49] };
return obj;
}, {}));
// Some use cli-color as: console.log(clc.red('Error!'));

@@ -79,8 +58,8 @@ // Which is inefficient as on each call it configures new clc object

var start = '', end = '', msg = join.call(arguments, ' '), conf = self._cliColorData
, hasAnsi = includes.call(msg, '\x1b[');
, hasAnsi = sgr.hasCSI(msg);
forEach(conf, function (mod, key) {
end = '\x1b[' + mod[1] + 'm' + end;
start += '\x1b[' + mod[0] + 'm';
end = sgr(mod[1]) + end;
start += sgr(mod[0]);
if (hasAnsi) {
msg = msg.replace(getEndRe(mod[1]), variantModes[key] ? '\x1b[' + mod[0] + 'm' : '');
msg = msg.replace(getEndRe(mod[1]), variantModes[key] ? sgr(mod[0]) : '');
}

@@ -87,0 +66,0 @@ }, null, true);

2

index.js

@@ -12,2 +12,4 @@ 'use strict';

strip: d(require('./strip')),
getStrippedLength: d(require('./get-stripped-length')),
slice: d(require('./slice')),
throbber: d(require('./throbber')),

@@ -14,0 +16,0 @@ reset: d(require('./reset')),

{
"name": "cli-color",
"version": "1.0.0",
"version": "1.1.0",
"description": "Colors, formatting and other tools for the console",

@@ -22,13 +22,13 @@ "author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)",

"dependencies": {
"ansi-regex": "^1.1.1",
"ansi-regex": "2",
"d": "^0.1.1",
"es5-ext": "^0.10.7",
"es6-iterator": "^0.1.3",
"memoizee": "~0.3.8",
"es5-ext": "^0.10.8",
"es6-iterator": "2",
"memoizee": "^0.3.9",
"timers-ext": "0.1"
},
"devDependencies": {
"tad": "^0.2.2",
"tad": "^0.2.3",
"xlint": "^0.2.2",
"xlint-jslint-medikoo": "^0.1.2"
"xlint-jslint-medikoo": "^0.1.4"
},

@@ -35,0 +35,0 @@ "scripts": {

@@ -590,2 +590,13 @@ # cli-color

#### clc.slice(str[, begin[, end]])
Slice provided string with preservation of eventual ANSI formatting
```javascript
var clc = require('cli-color')
var str = clc.bold('foo') + 'bar' + clc.red('elo');
var sliced = clc.slice(str, 1, 7); // Same as: clc.bold('oo') + 'bar' + clc.red('e')
```
#### clc.strip(formatedText)

@@ -601,2 +612,13 @@

#### clc.getStrippedLength(str, begin, end)
Slice provided string with preservation of eventual ANSI formatting
```javascript
var clc = require('cli-color');
var str = clc.bold('foo') + 'bar' + clc.red('elo');
clc.getStrippedLength(str); // 9
```
#### clc.art(text, styleConf)

@@ -639,5 +661,4 @@

* [@rentalhost](https://github.com/rentalhost) (David Rodrigues)
* Help with support for nested styles. Introduction of `clc.art` module, and significant improvements to tests coverage.
* Help with support for nested styles. Introduction of `clc.art` module, and significant improvements to tests coverage
* [@StreetStrider](https://github.com/StreetStrider)
* Implementation of sophistcated `clc.slice` functionality, and introduction of `clc.getStrippedLength` utility

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc