chroma-palette
Advanced tools
Comparing version 1.0.11 to 1.1.0
91
index.js
@@ -0,25 +1,59 @@ | ||
/** | ||
* A module that creates a tool for implementing color and formatting in strings. | ||
* @module chroma-palette | ||
*/ | ||
/** | ||
* Class Chroma - creates a tool for implementing color and formatting in strings. | ||
*/ | ||
class Chroma { | ||
/** | ||
* Create a Chroma | ||
* | ||
* @param {Object | undefined} color - contains color options | ||
* @param {string | undefined} color.profile | ||
* @param {string | undefined} color.orange | ||
* @param {string | undefined} color.purple | ||
* @param {string | undefined} color.black | ||
* @param {string | undefined} color.red | ||
* @param {string | undefined} color.green | ||
* @param {string | undefined} color.yellow | ||
* @param {string | undefined} color.blue | ||
* @param {string | undefined} color.magenta | ||
* @param {string | undefined} color.cyan | ||
* @param {string | undefined} color.white | ||
*/ | ||
constructor(color) { | ||
/** @private */ | ||
this.elements = ''; | ||
/** @private */ | ||
this.Reset = "\x1b[0m"; | ||
/** @private */ | ||
this.Bold = "\x1b[1m"; | ||
/** @private */ | ||
this.Dim = "\x1b[2m"; | ||
/** @private */ | ||
this.Underscore = "\x1b[4m"; | ||
/** @private */ | ||
this.Blink = "\x1b[5m"; | ||
/** @private */ | ||
this.Reverse = "\x1b[7m"; | ||
/** @private */ | ||
this.Hidden = "\x1b[8m"; | ||
/** @private */ | ||
this.FgOrange = color !== undefined && color.orange !== undefined | ||
? `\x1b[38;5;${color.orange}m` | ||
: "\x1b[38;5;208m"; | ||
/** @private */ | ||
this.FgPurple = color !== undefined && color.purple !== undefined | ||
? `\x1b[38;5;${color.purple}m` | ||
: "\x1b[38;5;141m"; | ||
/** @private */ | ||
this.FgBlack = color !== undefined && color.black !== undefined | ||
? `\x1b[38;5;${color.black}m` | ||
: "\x1b[30m"; | ||
/** @private */ | ||
this.FgRed = color !== undefined && color.profile !== undefined && color.profile === '16' | ||
@@ -30,2 +64,3 @@ ? "\x1b[31m" | ||
: "\x1b[38;5;9m"; | ||
/** @private */ | ||
this.FgGreen = color !== undefined && color.profile !== undefined && color.profile === '16' | ||
@@ -36,2 +71,3 @@ ? "\x1b[32m" | ||
: "\x1b[38;5;10m"; | ||
/** @private */ | ||
this.FgYellow = color !== undefined && color.profile !== undefined && color.profile === '16' | ||
@@ -42,2 +78,3 @@ ? "\x1b[33m" | ||
: "\x1b[38;5;221m"; | ||
/** @private */ | ||
this.FgBlue = color !== undefined && color.profile !== undefined && color.profile === '16' | ||
@@ -48,2 +85,3 @@ ? "\x1b[34m" | ||
: "\x1b[38;5;75m"; | ||
/** @private */ | ||
this.FgMagenta = color !== undefined && color.profile !== undefined && color.profile === '16' | ||
@@ -54,2 +92,3 @@ ? "\x1b[35m" | ||
: "\x1b[38;5;213m"; | ||
/** @private */ | ||
this.FgCyan = color !== undefined && color.profile !== undefined && color.profile === '16' | ||
@@ -60,2 +99,3 @@ ? "\x1b[36m" | ||
: "\x1b[38;5;123m"; | ||
/** @private */ | ||
this.FgWhite = color !== undefined && color.white !== undefined | ||
@@ -65,11 +105,15 @@ ? `\x1b[38;5;${color.white}m` | ||
/** @private */ | ||
this.BgOrange = color !== undefined && color.orange !== undefined | ||
? `\x1b[48;5;${color.orange}m` | ||
: "\x1b[48;5;208m"; | ||
/** @private */ | ||
this.BgPurple = color !== undefined && color.purple !== undefined | ||
? `\x1b[48;5;${color.purple}m` | ||
: "\x1b[48;5;141m"; | ||
/** @private */ | ||
this.BgBlack = color !== undefined && color.black !== undefined | ||
? `\x1b[48;5;${color.black}m` | ||
: "\x1b[40m"; | ||
/** @private */ | ||
this.BgRed = color !== undefined && color.profile !== undefined && color.profile === '16' | ||
@@ -80,2 +124,3 @@ ? "\x1b[41m" | ||
: "\x1b[48;5;9m"; | ||
/** @private */ | ||
this.BgGreen = color !== undefined && color.profile !== undefined && color.profile === '16' | ||
@@ -86,2 +131,3 @@ ? "\x1b[42m" | ||
: "\x1b[48;5;10m"; | ||
/** @private */ | ||
this.BgYellow = color !== undefined && color.profile !== undefined && color.profile === '16' | ||
@@ -92,2 +138,3 @@ ? "\x1b[43m" | ||
: "\x1b[48;5;221m"; | ||
/** @private */ | ||
this.BgBlue = color !== undefined && color.profile !== undefined && color.profile === '16' | ||
@@ -98,2 +145,3 @@ ? "\x1b[44m" | ||
: "\x1b[48;5;75m"; | ||
/** @private */ | ||
this.BgMagenta = color !== undefined && color.profile !== undefined && color.profile === '16' | ||
@@ -104,2 +152,3 @@ ? "\x1b[45m" | ||
: "\x1b[48;5;213m"; | ||
/** @private */ | ||
this.BgCyan = color !== undefined && color.profile !== undefined && color.profile === '16' | ||
@@ -110,2 +159,3 @@ ? "\x1b[46m" | ||
: "\x1b[48;5;123m"; | ||
/** @private */ | ||
this.BgWhite = color !== undefined && color.white !== undefined | ||
@@ -115,3 +165,3 @@ ? `\x1b[48;5;${color.white}m` | ||
} | ||
// Get formats | ||
/** @returns this - after adding dim to elements */ | ||
get dim() { | ||
@@ -121,2 +171,3 @@ this.elements += this.Dim; | ||
} | ||
/** @returns this - after adding underscore to elements */ | ||
get underscore() { | ||
@@ -126,2 +177,3 @@ this.elements += this.Underscore; | ||
} | ||
/** @returns this - after adding blink to elements */ | ||
get blink() { | ||
@@ -131,2 +183,3 @@ this.elements += this.Blink; | ||
} | ||
/** @returns this - after adding reverse to elements */ | ||
get reverse() { | ||
@@ -136,2 +189,3 @@ this.elements += this.Reverse; | ||
} | ||
/** @returns this - after adding hidden to elements */ | ||
get hidden() { | ||
@@ -141,2 +195,3 @@ this.elements += this.Hidden; | ||
} | ||
/** @returns this - after adding bold to elements */ | ||
get bold() { | ||
@@ -146,3 +201,4 @@ this.elements += this.Bold; | ||
} | ||
// Get text color | ||
// Text color | ||
/** @returns this - after adding blue to elements */ | ||
get blue() { | ||
@@ -152,2 +208,3 @@ this.elements += this.FgBlue; | ||
} | ||
/** @returns this - after adding cyan to elements */ | ||
get cyan() { | ||
@@ -157,2 +214,3 @@ this.elements += this.FgCyan; | ||
} | ||
/** @returns this - after adding purple to elements */ | ||
get purple() { | ||
@@ -162,2 +220,3 @@ this.elements += this.FgPurple; | ||
} | ||
/** @returns this - after adding magenta to elements */ | ||
get magenta() { | ||
@@ -167,2 +226,3 @@ this.elements += this.FgMagenta; | ||
} | ||
/** @returns this - after adding red to elements */ | ||
get red() { | ||
@@ -172,2 +232,3 @@ this.elements += this.FgRed; | ||
} | ||
/** @returns this - after adding orange to elements */ | ||
get orange() { | ||
@@ -177,2 +238,3 @@ this.elements += this.FgOrange; | ||
} | ||
/** @returns this - after adding yellow to elements */ | ||
get yellow() { | ||
@@ -182,2 +244,3 @@ this.elements += this.FgYellow; | ||
} | ||
/** @returns this - after adding green to elements */ | ||
get green() { | ||
@@ -187,2 +250,3 @@ this.elements += this.FgGreen; | ||
} | ||
/** @returns this - after adding white to elements */ | ||
get white() { | ||
@@ -192,2 +256,3 @@ this.elements += this.FgWhite; | ||
} | ||
/** @returns this - after adding black to elements */ | ||
get black() { | ||
@@ -198,2 +263,3 @@ this.elements += this.FgBlack; | ||
// Get background color | ||
/** @returns this - after adding blueBg to elements */ | ||
get blueBg() { | ||
@@ -203,2 +269,3 @@ this.elements += this.BgBlue; | ||
} | ||
/** @returns this - after adding cyanBg to elements */ | ||
get cyanBg() { | ||
@@ -208,2 +275,3 @@ this.elements += this.BgCyan; | ||
} | ||
/** @returns this - after adding purpleBg to elements */ | ||
get purpleBg() { | ||
@@ -213,2 +281,3 @@ this.elements += this.BgPurple; | ||
} | ||
/** @returns this - after adding magentaBg to elements */ | ||
get magentaBg() { | ||
@@ -218,2 +287,3 @@ this.elements += this.BgMagenta; | ||
} | ||
/** @returns this - after adding redBg to elements */ | ||
get redBg() { | ||
@@ -223,2 +293,3 @@ this.elements += this.BgRed; | ||
} | ||
/** @returns this - after adding orangeBg to elements */ | ||
get orangeBg() { | ||
@@ -228,2 +299,3 @@ this.elements += this.BgOrange; | ||
} | ||
/** @returns this - after adding yellowBg to elements */ | ||
get yellowBg() { | ||
@@ -233,2 +305,3 @@ this.elements += this.BgYellow; | ||
} | ||
/** @returns this - after adding greenBg to elements */ | ||
get greenBg() { | ||
@@ -238,2 +311,3 @@ this.elements += this.BgGreen; | ||
} | ||
/** @returns this - after adding whiteBg to elements */ | ||
get whiteBg() { | ||
@@ -243,2 +317,3 @@ this.elements += this.BgWhite; | ||
} | ||
/** @returns this - after adding blackBg to elements */ | ||
get blackBg() { | ||
@@ -249,2 +324,3 @@ this.elements += this.BgBlack; | ||
// Get all colors in 256 palette | ||
/** @returns this - after adding each color in palette to elements */ | ||
get palette() { | ||
@@ -258,3 +334,7 @@ const colors = [...Array(256 - 1 + 1).keys()].map(x => x + 1); | ||
} | ||
// Execute output of painting content | ||
/** | ||
* Execute output of painting content | ||
* @param {* | undefined} content - user content to add | ||
* @returns {string} returnContent - adding in the user contents to string and reset the elements in order to clear the Chroma. | ||
*/ | ||
paint(content) { | ||
@@ -268,2 +348,5 @@ let returnContent = `${this.elements}${content !== undefined ? content : ''}${this.Reset}`; | ||
/** | ||
* @type {typeof Chroma} | ||
*/ | ||
let chroma = new Chroma(); | ||
@@ -270,0 +353,0 @@ |
{ | ||
"name": "chroma-palette", | ||
"version": "1.0.11", | ||
"version": "1.1.0", | ||
"description": "A light-weight utility for coloring your terminal. 0 dependencies. Default is a preselected color output from the 256 color palette, chosen to enhance legibility.", | ||
@@ -27,12 +27,7 @@ "author": "Cal Young", | ||
"index.js", | ||
"index.d.ts", | ||
"types/index.d.ts", | ||
"examples/paint256.js", | ||
"examples/test.js" | ||
], | ||
"engines": { | ||
"node": ">=14.13.0" | ||
}, | ||
"lib": [ | ||
"es2016" | ||
], | ||
"types": "types/index.d.ts", | ||
"devDependencies": { | ||
@@ -39,0 +34,0 @@ }, |
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
16052
404