Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eight-colors

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eight-colors - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

dist/eight-colors.js

34

lib/index.js

@@ -1,7 +0,2 @@

const EC = {
bg: {},
br: {
bg: {}
}
};
const EC = {};

@@ -19,2 +14,3 @@ const add = (start, str, end) => {

//text color
list.forEach((name, i) => {

@@ -24,8 +20,23 @@ EC[name] = (str) => {

};
});
//background color
EC.bg = {};
list.forEach((name, i) => {
EC.bg[name] = (str) => {
return add(`4${i}`, str, '49');
};
});
//bright color
EC.br = {};
list.forEach((name, i) => {
EC.br[name] = (str) => {
return add(`9${i}`, str, '39');
};
});
//bright background color
EC.br.bg = {};
list.forEach((name, i) => {
EC.br.bg[name] = (str) => {

@@ -36,3 +47,4 @@ return add(`10${i}`, str, '49');

//other
//styles
EC.reset = (str) => {

@@ -63,3 +75,3 @@ return add('0', str, '0');

//remove color API
//remove color
EC.remove = (str) => {

@@ -69,3 +81,3 @@ return `${str}`.replace(/\033\[(\d+)m/g, '');

//log color API
//log color
EC.log = (str) => {

@@ -84,3 +96,3 @@ console.log(str);

list.forEach(color => {
list.forEach((color) => {
const api = `log${color.charAt(0).toUpperCase()}${color.slice(1)}`;

@@ -92,2 +104,2 @@ EC[api] = function(str) {

module.exports = EC;
module.exports = EC;
{
"name": "eight-colors",
"version": "1.0.1",
"description": "eight colors",
"version": "1.0.2",
"description": "Eight colors for the console",
"main": "lib/index.js",
"browser": {
"eight-colors": "dist/eight-colors.js"
},
"files": [
"lib"
"lib",
"dist"
],

@@ -14,8 +18,11 @@ "repository": {

"scripts": {
"test": "node ./test/test.js"
"test": "node ./scripts/test.js",
"build": "sf lint && sf b -p",
"patch": "npm run build && sf publish patch -r"
},
"devDependencies": {
"eslint": "^8.13.0"
},
"dependencies": {}
}
"eslint": "^8.22.0",
"eslint-config-plus": "^1.0.3",
"eslint-plugin-html": "^7.1.0"
}
}
# Eight Colors
> Eight colors for the terminal console
> Eight colors for the console
## Install

@@ -9,7 +8,10 @@ ```

## APIs
* eight colors: black, red, green, yellow, blue, magenta, cyan, white
* styles: reset, bold, faint, italic, underline, inverse, hidden, strike
* remove color
* log color
## Features
* Eight Colors: black, red, green, yellow, blue, magenta, cyan, white
* Background and Bright
* Styles: reset, bold, faint, italic, underline, inverse, hidden, strike
* Remove colors
* Log colors
## Usage

@@ -19,31 +21,123 @@ ```js

//normal font color
console.log(EC.red("red string"));
//text color
console.log(EC.red('red string'));
//background color
console.log(EC.bg.red("red background"));
console.log(EC.bg.red('red background'));
//bright
console.log(EC.br.red("bright red string"));
//bright color
console.log(EC.br.red('bright red string'));
//bright background
console.log(EC.br.bg.red("bright red background"));
//bright background color
console.log(EC.br.bg.red('bright red background'));
const redString = EC.red("red string");
console.log(redString);
//style
console.log(EC.italic('italic text'));
console.log(EC.underline('underline text'));
console.log(EC.green(EC.underline('green underline text')));
//remove color
const redString = EC.red('red string');
console.log(redString);
const string = EC.remove(redString);
console.log(string === "red string");
console.assert(string === 'red string');
//log color
EC.logColor("string", "red");
EC.logGreen('green string');
EC.logRed('red string');
EC.logCyan('cyan string');
EC.logColor('string', 'red');
EC.logGreen('log green');
EC.logRed('log red');
EC.logCyan('log cyan');
EC.logBlack('log black');
EC.logWhite('log white');
//check out all APIs
console.log(EC);
```
![](/scripts/screenshots.png)
## Changelog
## All APIs
```js
EC.black(String)
EC.red(String)
EC.green(String)
EC.yellow(String)
EC.blue(String)
EC.magenta(String)
EC.cyan(String)
EC.white(String)
EC.bg.black(String)
EC.bg.red(String)
EC.bg.green(String)
EC.bg.yellow(String)
EC.bg.blue(String)
EC.bg.magenta(String)
EC.bg.cyan(String)
EC.bg.white(String)
EC.br.black(String)
EC.br.red(String)
EC.br.green(String)
EC.br.yellow(String)
EC.br.blue(String)
EC.br.magenta(String)
EC.br.cyan(String)
EC.br.white(String)
EC.br.bg.black(String)
EC.br.bg.red(String)
EC.br.bg.green(String)
EC.br.bg.yellow(String)
EC.br.bg.blue(String)
EC.br.bg.magenta(String)
EC.br.bg.cyan(String)
EC.br.bg.white(String)
EC.reset(String)
EC.bold(String)
EC.faint(String)
EC.italic(String)
EC.underline(String)
EC.inverse(String)
EC.hidden(String)
EC.strike(String)
EC.remove(String)
EC.log(String)
EC.logColor(String, Color)
EC.logBlack(String)
EC.logRed(String)
EC.logGreen(String)
EC.logYellow(String)
EC.logBlue(String)
EC.logMagenta(String)
EC.logCyan(String)
EC.logWhite(String)
```
## Browser Console
Usage is the same as above, and provides an additional UMD bundle (1.35 KB)
```html
<script src="path-to/eight-colors/dist/eight-colors.js"></script>
<script>
const EC = window['eight-colors'];
console.log(EC.red('red string'));
</script>
```
![](/scripts/browser.png)
## Links
- [https://en.wikipedia.org/wiki/ANSI_escape_code](https://en.wikipedia.org/wiki/ANSI_escape_code)
- [https://handwiki.org/wiki/ANSI_escape_code](https://handwiki.org/wiki/ANSI_escape_code)
![](/scripts/eight-colors.png)
## CHANGELOG
* 1.0.2
* added browser bundle
* 1.0.1

@@ -50,0 +144,0 @@ * added log color API

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