New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ccolor

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ccolor - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

colors.js

92

app.js

@@ -1,7 +0,3 @@

// Constants.
const COLOR_DEFAULT = '\x1b[0m';
const COLOR_BLUE = '\x1b[34m';
const COLOR_GREEN = '\x1b[32m';
const COLOR_YELLOW = '\x1b[33m';
const COLOR_RED = '\x1b[31m';
// Import.
const colors = require('./colors');

@@ -13,2 +9,20 @@ /**

/**
* Black.
* @param {string} text - Text.
* @return {string}
*/
static black(text = '') {
return setColor(text, colors.foreground.black);
}
/**
* White.
* @param {string} text - Text.
* @return {string}
*/
static white(text = '') {
return setColor(text, colors.foreground.white);
}
/**
* Blue.

@@ -19,3 +33,3 @@ * @param {string} text - Text.

static blue(text = '') {
return setColor(text, COLOR_BLUE);
return setColor(text, colors.foreground.blue);
}

@@ -29,3 +43,3 @@

static green(text = '') {
return setColor(text, COLOR_GREEN);
return setColor(text, colors.foreground.green);
}

@@ -39,3 +53,3 @@

static yellow(text = '') {
return setColor(text, COLOR_YELLOW);
return setColor(text, colors.foreground.yellow);
}

@@ -49,4 +63,58 @@

static red(text = '') {
return setColor(text, COLOR_RED);
return setColor(text, colors.foreground.red);
}
/**
* Black background.
* @param {string} text - Text.
* @return {string}
*/
static blackBackground(text = '') {
return setColor(text, colors.background.black);
}
/**
* White background.
* @param {string} text - Text.
* @return {string}
*/
static whiteBackground(text = '') {
return setColor(text, colors.background.white);
}
/**
* Blue background.
* @param {string} text - Text.
* @return {string}
*/
static blueBackground(text = '') {
return setColor(text, colors.background.blue);
}
/**
* Green background.
* @param {string} text - Text.
* @return {string}
*/
static greenBackground(text = '') {
return setColor(text, colors.background.green);
}
/**
* Yellow background.
* @param {string} text - Text.
* @return {string}
*/
static yellowBackground(text = '') {
return setColor(text, colors.background.yellow);
}
/**
* Red background.
* @param {string} text - Text.
* @return {string}
*/
static redBackground(text = '') {
return setColor(text, colors.background.red);
}
}

@@ -59,4 +127,4 @@

*/
function setColor(text = '', color = COLOR_DEFAULT) {
return `${color}${text}${COLOR_DEFAULT}`;
function setColor(text = '', color = colors.reset) {
return `${color}${text}${colors.reset}`;
}

@@ -63,0 +131,0 @@

2

package.json
{
"name": "ccolor",
"version": "1.0.1",
"version": "1.1.0",
"description": "Console color",

@@ -5,0 +5,0 @@ "main": "app.js",

@@ -23,7 +23,20 @@ # CColor

```js
// Show text with color.
console.log(CColor.green('Green text.'));
console.log(CColor.blue('Blue text.'));
console.log(CColor.yellow('Yellow text.'));
console.log(CColor.red('Red text.'));
// Colored foregrounds.
console.log(CColor.black('Black foreground.'));
console.log(CColor.white('White foreground.'));
console.log(CColor.green('Green foreground.'));
console.log(CColor.blue('Blue foreground.'));
console.log(CColor.yellow('Yellow foreground.'));
console.log(CColor.red('Red foreground.'));
// Colored backgrounds.
console.log(CColor.blackBackground('Black background.'));
console.log(CColor.whiteBackground('White background.'));
console.log(CColor.greenBackground('Green background.'));
console.log(CColor.blueBackground('Blue background.'));
console.log(CColor.yellowBackground('Yellow background.'));
console.log(CColor.redBackground('Red background.'));
// Colored foreground and backgrounds at the same time.
console.log(CColor.yellowBackground(CColor.red('Red foreground with yellow background.')));
```

@@ -30,0 +43,0 @@

// Import.
const CColor = require('./app');
// Test.
console.log(CColor.green('Green text.'));
console.log(CColor.blue('Blue text.'));
console.log(CColor.yellow('Yellow text.'));
console.log(CColor.red('Red text.'));
// Test foregrounds.
console.log('Foregrounds:');
console.log('------------');
console.log(CColor.black('Black foreground.'));
console.log(CColor.white('White foreground.'));
console.log(CColor.green('Green foreground.'));
console.log(CColor.blue('Blue foreground.'));
console.log(CColor.yellow('Yellow foreground.'));
console.log(CColor.red('Red foreground.'));
// Test backgrounds.
console.log('\nBackgrounds:');
console.log('--------------');
console.log(CColor.blackBackground('Black background.'));
console.log(CColor.whiteBackground('White background.'));
console.log(CColor.greenBackground('Green background.'));
console.log(CColor.blueBackground('Blue background.'));
console.log(CColor.yellowBackground('Yellow background.'));
console.log(CColor.redBackground('Red background.'));
// Test mixed.
console.log('\nMixed:');
console.log('--------');
console.log(CColor.yellowBackground(CColor.red('Red foreground with yellow background.')));
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