eight-colors
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,2 +0,2 @@ | ||
!function(o,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("eight-colors",[],e):"object"==typeof exports?exports["eight-colors"]=e():o["eight-colors"]=e()}(self,(()=>{return o={578:o=>{const e={},t=(o,e,t)=>"[".concat(o,"m").concat(e,"[").concat(t,"m"),c=["black","red","green","yellow","blue","magenta","cyan","white"];c.forEach(((o,c)=>{e[o]=o=>t("3".concat(c),o,"39")})),e.bg={},c.forEach(((o,c)=>{e.bg[o]=o=>t("4".concat(c),o,"49")})),e.br={},c.forEach(((o,c)=>{e.br[o]=o=>t("9".concat(c),o,"39")})),e.br.bg={},c.forEach(((o,c)=>{e.br.bg[o]=o=>t("10".concat(c),o,"49")})),e.reset=o=>t("0",o,"0"),e.bold=o=>t("1",o,"21"),e.faint=o=>t("2",o,"22"),e.italic=o=>t("3",o,"23"),e.underline=o=>t("4",o,"24"),e.inverse=o=>t("7",o,"27"),e.hidden=o=>t("8",o,"28"),e.strike=o=>t("9",o,"29"),e.remove=o=>"".concat(o).replace(/\033\[(\d+)m/g,""),e.log=o=>{console.log(o)},e.logColor=(o,t)=>{const c=e[t];return"function"==typeof c&&(o=c(o)),e.log(o),o},c.forEach((o=>{const t="log".concat(o.charAt(0).toUpperCase()).concat(o.slice(1));e[t]=function(t){return e.logColor(t,o)}})),o.exports=e},148:(o,e,t)=>{const c=t(578);o.exports=c}},e={},t=function t(c){var r=e[c];if(void 0!==r)return r.exports;var n=e[c]={exports:{}};return o[c](n,n.exports,t),n.exports}(148),t;var o,e,t})); | ||
!function(o,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("eight-colors",[],e):"object"==typeof exports?exports["eight-colors"]=e():o["eight-colors"]=e()}(self,(()=>{return o={578:o=>{const e={},r=(o,e,r)=>`[${o}m${e}[${r}m`,t=["black","red","green","yellow","blue","magenta","cyan","white"];t.forEach(((o,t)=>{e[o]=o=>r(`3${t}`,o,"39")})),e.bg={},t.forEach(((o,t)=>{e.bg[o]=o=>r(`4${t}`,o,"49")})),e.br={},t.forEach(((o,t)=>{e.br[o]=o=>r(`9${t}`,o,"39")})),e.br.bg={},t.forEach(((o,t)=>{e.br.bg[o]=o=>r(`10${t}`,o,"49")})),e.reset=o=>r("0",o,"0"),e.bold=o=>r("1",o,"21"),e.faint=o=>r("2",o,"22"),e.italic=o=>r("3",o,"23"),e.underline=o=>r("4",o,"24"),e.inverse=o=>r("7",o,"27"),e.hidden=o=>r("8",o,"28"),e.strike=o=>r("9",o,"29"),e.remove=o=>`${o}`.replace(/\033\[(\d+)m/g,""),e.log=function(){console.log.apply(console,arguments)},e.logColor=function(){const o=Array.from(arguments),r=o.pop();let t;const n=e[r];return"function"==typeof n?t=n(o.join(" ")):(o.push(r),t=o.join(" ")),e.log(t),t},t.forEach((o=>{const r=`log${o.charAt(0).toUpperCase()}${o.slice(1)}`;e[r]=function(){const r=Array.from(arguments);return r.push(o),e.logColor.apply(e,r)}})),o.exports=e},148:(o,e,r)=>{const t=r(578);o.exports=t}},e={},function r(t){var n=e[t];if(void 0!==n)return n.exports;var c=e[t]={exports:{}};return o[t](c,c.exports,r),c.exports}(148);var o,e})); | ||
//# sourceMappingURL=eight-colors.js.map |
@@ -77,11 +77,17 @@ const EC = {}; | ||
//log color | ||
EC.log = (str) => { | ||
console.log(str); | ||
//log hook | ||
EC.log = function() { | ||
console.log.apply(console, arguments); | ||
}; | ||
EC.logColor = (str, color) => { | ||
EC.logColor = function() { | ||
const args = Array.from(arguments); | ||
const color = args.pop(); | ||
let str; | ||
const fn = EC[color]; | ||
if (typeof (fn) === 'function') { | ||
str = fn(str); | ||
if (typeof fn === 'function') { | ||
str = fn(args.join(' ')); | ||
} else { | ||
args.push(color); | ||
str = args.join(' '); | ||
} | ||
@@ -94,4 +100,6 @@ EC.log(str); | ||
const api = `log${color.charAt(0).toUpperCase()}${color.slice(1)}`; | ||
EC[api] = function(str) { | ||
return EC.logColor(str, color); | ||
EC[api] = function() { | ||
const args = Array.from(arguments); | ||
args.push(color); | ||
return EC.logColor.apply(EC, args); | ||
}; | ||
@@ -98,0 +106,0 @@ }); |
{ | ||
"name": "eight-colors", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Eight colors for the console", | ||
@@ -9,2 +9,7 @@ "main": "lib/index.js", | ||
}, | ||
"scripts": { | ||
"test": "node ./scripts/test.js", | ||
"build": "sf lint && sf b -p", | ||
"patch": "npm run build && sf publish patch -r" | ||
}, | ||
"files": [ | ||
@@ -18,12 +23,8 @@ "lib", | ||
}, | ||
"scripts": { | ||
"test": "node ./scripts/test.js", | ||
"build": "sf lint && sf b -p", | ||
"patch": "npm run build && sf publish patch -r" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"eslint": "^8.22.0", | ||
"eslint-config-plus": "^1.0.3", | ||
"eslint": "^8.36.0", | ||
"eslint-config-plus": "^1.0.6", | ||
"eslint-plugin-html": "^7.1.0" | ||
} | ||
} |
# Eight Colors | ||
> Eight colors for the console | ||
![](/scripts/eight-colors.png) | ||
## Install | ||
@@ -20,2 +22,5 @@ ``` | ||
//check out all APIs | ||
console.log(EC); | ||
//text color | ||
@@ -53,4 +58,7 @@ console.log(EC.red('red string')); | ||
//check out all APIs | ||
console.log(EC); | ||
EC.log('log 2 arguments', '2'); | ||
EC.logGreen('logGreen 2 arguments', '2'); | ||
EC.logMagenta('logMagenta 3 arguments', '2', '3'); | ||
EC.logColor('logColor 2 arguments with color', '2', 'red'); | ||
EC.logColor('logColor 2 arguments without color', '2'); | ||
@@ -133,2 +141,4 @@ ``` | ||
* firefox does not support | ||
## Links | ||
@@ -138,5 +148,7 @@ - [https://en.wikipedia.org/wiki/ANSI_escape_code](https://en.wikipedia.org/wiki/ANSI_escape_code) | ||
![](/scripts/eight-colors.png) | ||
## CHANGELOG | ||
* 1.0.3 | ||
* fixed API multiple arguments | ||
* 1.0.2 | ||
@@ -143,0 +155,0 @@ * added browser bundle |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15254
98
156