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.2.1 to 1.3.0

2

dist/eight-colors.js

@@ -1,1 +0,1 @@

!function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define("eight-colors",[],o):"object"==typeof exports?exports["eight-colors"]=o():e["eight-colors"]=o()}(self,(()=>{return e={578:e=>{const o={},r=(e,o,r)=>`[${e}m${o}[${r}m`,t=["black","red","green","yellow","blue","magenta","cyan","white"];t.forEach(((e,t)=>{o[e]=e=>r(`3${t}`,e,"39")})),o.bg={},t.forEach(((e,t)=>{o.bg[e]=e=>r(`4${t}`,e,"49")})),o.br={},t.forEach(((e,t)=>{o.br[e]=e=>r(`9${t}`,e,"39")})),o.br.bg={},t.forEach(((e,t)=>{o.br.bg[e]=e=>r(`10${t}`,e,"49")})),o.reset=e=>r("0",e,"0"),o.bold=e=>r("1",e,"21"),o.faint=e=>r("2",e,"22"),o.italic=e=>r("3",e,"23"),o.underline=e=>r("4",e,"24"),o.inverse=e=>r("7",e,"27"),o.hidden=e=>r("8",e,"28"),o.strike=e=>r("9",e,"29"),o.remove=e=>`${e}`.replace(/\033\[(\d+)m/g,""),o.log=function(e){console.log(e)},t.forEach((e=>{const r=`log${e.charAt(0).toUpperCase()}${e.slice(1)}`;o[r]=function(){const r=Array.from(arguments),t=(0,o[e])(o.remove(r.join(" ")));return o.log(t),t}})),e.exports=o},148:(e,o,r)=>{const t=r(578);e.exports=t}},o={},function r(t){var n=o[t];if(void 0!==n)return n.exports;var c=o[t]={exports:{}};return e[t](c,c.exports,r),c.exports}(148);var e,o}));
!function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define("eight-colors",[],o):"object"==typeof exports?exports["eight-colors"]=o():e["eight-colors"]=o()}(self,(()=>{return e={329:e=>{const o=["black","red","green","yellow","blue","magenta","cyan","white"],r={};let t=!1;Object.defineProperty(r,"disabled",{get:function(){return t},set:function(e){t=e}});const n=(e,o,r)=>t?o:`[${e}m${o}[${r}m`;o.forEach(((e,o)=>{r[e]=e=>n(`3${o}`,e,"39")})),r.bg={},o.forEach(((e,o)=>{r.bg[e]=e=>n(`4${o}`,e,"49")})),r.br={},o.forEach(((e,o)=>{r.br[e]=e=>n(`9${o}`,e,"39")})),r.br.bg={},o.forEach(((e,o)=>{r.br.bg[e]=e=>n(`10${o}`,e,"49")})),r.reset=e=>n("0",e,"0"),r.bold=e=>n("1",e,"21"),r.faint=e=>n("2",e,"22"),r.italic=e=>n("3",e,"23"),r.underline=e=>n("4",e,"24"),r.inverse=e=>n("7",e,"27"),r.hidden=e=>n("8",e,"28"),r.strike=e=>n("9",e,"29"),r.remove=e=>`${e}`.replace(/\033\[(\d+)m/g,""),r.log=function(e){arguments.length>1&&(e=Array.from(arguments).join(" ")),console.log(e)},o.forEach((e=>{const o=`log${e.charAt(0).toUpperCase()}${e.slice(1)}`;r[o]=function(){const o=Array.from(arguments),t=(0,r[e])(r.remove(o.join(" ")));return r.log(t),t}})),e.exports=r},379:(e,o,r)=>{const t=r(329);e.exports=t}},o={},function r(t){var n=o[t];if(void 0!==n)return n.exports;var c=o[t]={exports:{}};return e[t](c,c.exports,r),c.exports}(379);var e,o}));

@@ -24,2 +24,4 @@ type ColorHandler = (str: string) => string

disabled: boolean;
bg: IEightColors,

@@ -26,0 +28,0 @@

@@ -0,16 +1,29 @@

// https://en.wikipedia.org/wiki/ANSI_escape_code
// https://handwiki.org/wiki/ANSI_escape_code
// eight colors
// 0 - 7
const eightColors = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'];
const EC = {};
let _disabled = false;
Object.defineProperty(EC, 'disabled', {
get: function() {
return _disabled;
},
set: function(v) {
_disabled = v;
}
});
const add = (start, str, end) => {
if (_disabled) {
return str;
}
return `\x1b[${start}m${str}\x1b[${end}m`;
};
// https://en.wikipedia.org/wiki/ANSI_escape_code
// https://handwiki.org/wiki/ANSI_escape_code
// eight colors
// 0 - 7
const list = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'];
// text color
list.forEach((name, i) => {
eightColors.forEach((name, i) => {
EC[name] = (str) => {

@@ -23,3 +36,3 @@ return add(`3${i}`, str, '39');

EC.bg = {};
list.forEach((name, i) => {
eightColors.forEach((name, i) => {
EC.bg[name] = (str) => {

@@ -32,3 +45,3 @@ return add(`4${i}`, str, '49');

EC.br = {};
list.forEach((name, i) => {
eightColors.forEach((name, i) => {
EC.br[name] = (str) => {

@@ -41,3 +54,3 @@ return add(`9${i}`, str, '39');

EC.br.bg = {};
list.forEach((name, i) => {
eightColors.forEach((name, i) => {
EC.br.bg[name] = (str) => {

@@ -82,6 +95,9 @@ return add(`10${i}`, str, '49');

EC.log = function(str) {
if (arguments.length > 1) {
str = Array.from(arguments).join(' ');
}
console.log(str);
};
list.forEach((color) => {
eightColors.forEach((color) => {
const api = `log${color.charAt(0).toUpperCase()}${color.slice(1)}`;

@@ -88,0 +104,0 @@ EC[api] = function() {

{
"name": "eight-colors",
"version": "1.2.1",
"version": "1.3.0",
"description": "Eight colors for the console",

@@ -34,8 +34,7 @@ "main": "./lib/index.js",

},
"dependencies": {},
"devDependencies": {
"eslint": "^8.56.0",
"eslint-config-plus": "^1.0.6",
"eslint-plugin-html": "^7.1.0"
"eslint-plugin-html": "^8.0.0"
}
}

@@ -59,2 +59,8 @@ # Eight Colors

// disabled color
EC.disabled = true;
EC.logRed('disabled = true log default');
EC.disabled = false;
EC.logRed('disabled = false log red');
```

@@ -121,2 +127,4 @@ ![](/scripts/screenshots.png)

EC.logWhite(str)
EC.disabled = true|false
```

@@ -143,2 +151,5 @@

* 1.3.0
- added `disabled` property, defaults to `false`
* 1.2.1

@@ -145,0 +156,0 @@ - fixed types for commonjs

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