Comparing version 3.1.1 to 3.2.0
#!/usr/bin/env node | ||
/*************************************************************************************************************************************************************** | ||
@@ -4,0 +3,0 @@ * |
@@ -15,2 +15,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -21,6 +22,6 @@ | ||
} = require('./Debugging.js'); | ||
const { | ||
Colorize | ||
} = require('./Colorize.js'); | ||
/** | ||
@@ -38,4 +39,2 @@ * Add a new character to the output array | ||
*/ | ||
const AddChar = (CHAR, output, fontLines, fontChars, fontColors, colors) => { | ||
@@ -50,8 +49,6 @@ Debugging.report(`Running AddChar with "${CHAR}"`, 1); | ||
} | ||
return output; | ||
}; | ||
module.exports = exports = { | ||
AddChar | ||
}; |
@@ -15,2 +15,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -21,6 +22,6 @@ | ||
} = require('./Debugging.js'); | ||
const { | ||
Colorize | ||
} = require('./Colorize.js'); | ||
/** | ||
@@ -38,4 +39,2 @@ * Add letter spacing for the next character | ||
*/ | ||
const AddLetterSpacing = (output, fontLines, fontLetterspace, fontColors, colors, letterSpacing) => { | ||
@@ -49,3 +48,2 @@ Debugging.report(`Running AddLetterSpacing`, 1); | ||
let space = Colorize(fontLetterspace[index], fontColors, colors); | ||
if (space.length === 0 && letterSpacing > 0) { | ||
@@ -55,11 +53,8 @@ Debugging.report(`AddLetterSpacing: Adding space to letter spacing`, 1); | ||
} | ||
output[i] += space.repeat(letterSpacing); | ||
} | ||
return output; | ||
}; | ||
module.exports = exports = { | ||
AddLetterSpacing | ||
}; |
@@ -15,2 +15,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -21,2 +22,3 @@ | ||
} = require('./Debugging.js'); | ||
/** | ||
@@ -32,17 +34,11 @@ * Add a new line to the output array | ||
*/ | ||
const AddLine = (output, fontLines, FontBuffer, lineHeight) => { | ||
Debugging.report(`Running AddLine`, 1); | ||
if (output.length === 0) { | ||
lineHeight = 0; | ||
} | ||
let lines = fontLines + output.length + lineHeight; | ||
let length = output.length; | ||
for (let i = length; i < lines; i++) { | ||
let index = i - length; | ||
if (index > lineHeight) { | ||
@@ -54,8 +50,6 @@ output[i] = FontBuffer[index - lineHeight]; | ||
} | ||
return output; | ||
}; | ||
module.exports = exports = { | ||
AddLine | ||
}; |
@@ -15,3 +15,5 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
/** | ||
@@ -24,3 +26,2 @@ * Flatten the shortcuts in our cli options object | ||
*/ | ||
const AddShortcuts = options => { | ||
@@ -31,3 +32,2 @@ const flatOptions = Object.assign({}, options); | ||
flatOptions[flatOptions[option].short] = flatOptions[option]; | ||
if (flatOptions[option].fallback_shortcut) { | ||
@@ -39,5 +39,4 @@ flatOptions[flatOptions[option].fallback_shortcut] = flatOptions[option]; | ||
}; | ||
module.exports = exports = { | ||
AddShortcuts | ||
}; |
@@ -15,2 +15,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -21,6 +22,6 @@ | ||
} = require('./Debugging.js'); | ||
const { | ||
Size | ||
} = require('./Size.js'); | ||
/** | ||
@@ -39,8 +40,5 @@ * Calculate the spaces to be added to the left of each line to align them either center or right | ||
*/ | ||
const AlignText = (output, lineLength, characterLines, align, size = Size) => { | ||
Debugging.report(`Running AlignText`, 1); | ||
let space = 0; | ||
if (align === 'center') { | ||
@@ -51,3 +49,2 @@ // calculate the size for center alignment | ||
} | ||
if (align === 'right') { | ||
@@ -58,9 +55,6 @@ // calculate the size for right alignment | ||
} | ||
if (space > 0) { | ||
// only add if there is something to add | ||
let lines = output.length - characterLines; // last line is characterLines tall and is located at the bottom of the output array | ||
const spaces = ' '.repeat(space); | ||
for (let i = lines; i < output.length; i++) { | ||
@@ -71,8 +65,6 @@ // iterate over last line (which can be several line breaks long) | ||
} | ||
return output; | ||
}; | ||
module.exports = exports = { | ||
AlignText | ||
}; |
@@ -15,2 +15,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -21,2 +22,3 @@ | ||
} = require('./Debugging.js'); | ||
/** | ||
@@ -31,8 +33,5 @@ * Return the max width of a character by looking at its longest line | ||
*/ | ||
const CharLength = (character, fontLines, letterSpacing) => { | ||
Debugging.report(`Running CharLength`, 1); | ||
let charWidth = 0; | ||
for (let i = 0; i < fontLines; i++) { | ||
@@ -50,8 +49,6 @@ let char = character[i].replace(/(<([^>]+)>)/gi, ''); // get character and strip color infos | ||
} | ||
return charWidth; | ||
}; | ||
module.exports = exports = { | ||
CharLength | ||
}; |
@@ -15,2 +15,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -22,3 +23,2 @@ | ||
} = require('./Color.js'); | ||
const { | ||
@@ -32,2 +32,3 @@ COLORS, | ||
} = require('./constants.js'); | ||
/** | ||
@@ -57,4 +58,2 @@ * Check input for human errors | ||
*/ | ||
const CheckInput = (INPUT, userFont, userColors, userBackground, userAlign, userGradient, userTransitionGradient, userEnv, fontfaces = FONTFACES, colors = COLORS, bgcolors = BGCOLORS, gradientcolors = GRADIENTCOLORS, gradients = GRADIENTS, alignment = ALIGNMENT) => { | ||
@@ -72,4 +71,5 @@ let result = { | ||
close: green_close | ||
} = Color('green'); // checking input | ||
} = Color('green'); | ||
// checking input | ||
if (INPUT === undefined || INPUT === '') { | ||
@@ -80,5 +80,5 @@ return { | ||
}; | ||
} // checking font | ||
} | ||
// checking font | ||
if (Object.keys(fontfaces).indexOf(userFont.toLowerCase()) === -1) { | ||
@@ -89,5 +89,5 @@ return { | ||
}; | ||
} // checking colors | ||
} | ||
// checking colors | ||
userColors.forEach(color => { | ||
@@ -101,4 +101,5 @@ // check color usage | ||
} | ||
}); // checking background colors | ||
}); | ||
// checking background colors | ||
if (Object.keys(bgcolors).indexOf(userBackground.toLowerCase()) === -1 && !HEXTEST.test(userBackground)) { | ||
@@ -109,5 +110,5 @@ return { | ||
}; | ||
} // CHECKING ALIGNMENT | ||
} | ||
// CHECKING ALIGNMENT | ||
if (alignment.indexOf(userAlign.toLowerCase()) === -1) { | ||
@@ -118,5 +119,5 @@ return { | ||
}; | ||
} // CHECKING GRADIENT | ||
} | ||
// CHECKING GRADIENT | ||
if (userGradient) { | ||
@@ -132,3 +133,2 @@ if (userGradient.length === 1 && Object.keys(gradients).indexOf(userGradient[0].toLowerCase()) !== -1 && userTransitionGradient) { | ||
} | ||
if (userGradient.length !== 2 && !userTransitionGradient) { | ||
@@ -139,5 +139,5 @@ return { | ||
}; | ||
} // check validity of colors | ||
} | ||
// check validity of colors | ||
userGradient.forEach(color => { | ||
@@ -152,5 +152,5 @@ if (Object.keys(gradientcolors).indexOf(color.toLowerCase()) === -1 && !HEXTEST.test(color)) { | ||
} | ||
} // CHECKING ENVIRONMENT | ||
} | ||
// CHECKING ENVIRONMENT | ||
if (userEnv !== 'node' && userEnv !== 'browser') { | ||
@@ -162,8 +162,6 @@ return { | ||
} | ||
return result; | ||
}; | ||
module.exports = exports = { | ||
CheckInput | ||
}; |
@@ -15,2 +15,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -21,2 +22,3 @@ | ||
} = require('./constants.js'); | ||
/** | ||
@@ -30,4 +32,2 @@ * Filter only allowed character | ||
*/ | ||
const CleanInput = (INPUT, chars = CHARS) => { | ||
@@ -41,5 +41,4 @@ if (typeof INPUT === 'string') { | ||
}; | ||
module.exports = exports = { | ||
CleanInput | ||
}; |
124
lib/Color.js
@@ -28,2 +28,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -34,6 +35,6 @@ | ||
} = require('supports-color'); | ||
const { | ||
Options | ||
} = require('./Options.js'); | ||
/** | ||
@@ -44,5 +45,4 @@ * Regex to see if a string is a hex color | ||
*/ | ||
const HEXTEST = RegExp('^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$'); | ||
const HEXTEST = RegExp('^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$'); | ||
/** | ||
@@ -60,3 +60,2 @@ * Converts an RGB color value to HSV | ||
*/ | ||
function Rgb2hsv({ | ||
@@ -75,4 +74,5 @@ r, | ||
let v = max; | ||
let s = max === 0 ? 0 : diff / max; // h | ||
let s = max === 0 ? 0 : diff / max; | ||
// h | ||
if (max === min) { | ||
@@ -90,5 +90,5 @@ h = 0; | ||
} | ||
return [h, s * 100, v * 100]; | ||
} | ||
/** | ||
@@ -110,4 +110,2 @@ * Converts an HSV color value to RGB | ||
*/ | ||
function Hsv2rgb(h, s, v) { | ||
@@ -123,3 +121,2 @@ h /= 60; | ||
v *= 255; | ||
switch (hi) { | ||
@@ -132,3 +129,2 @@ case 0: | ||
}; | ||
case 1: | ||
@@ -140,3 +136,2 @@ return { | ||
}; | ||
case 2: | ||
@@ -148,3 +143,2 @@ return { | ||
}; | ||
case 3: | ||
@@ -156,3 +150,2 @@ return { | ||
}; | ||
case 4: | ||
@@ -164,3 +157,2 @@ return { | ||
}; | ||
case 5: | ||
@@ -174,2 +166,3 @@ return { | ||
} | ||
/** | ||
@@ -184,4 +177,2 @@ * Converts RGB to HEX | ||
*/ | ||
function Rgb2hex(r, g, b) { | ||
@@ -191,2 +182,3 @@ const val = (b | g << 8 | r << 16 | 1 << 24).toString(16).slice(1); | ||
} | ||
/** | ||
@@ -199,19 +191,13 @@ * Convert HEX to RGB | ||
*/ | ||
function Hex2rgb(hex) { | ||
hex = hex.replace(/^#/, ''); | ||
if (hex.length > 6) { | ||
hex = hex.slice(0, 6); | ||
} | ||
if (hex.length === 4) { | ||
hex = hex.slice(0, 3); | ||
} | ||
if (hex.length === 3) { | ||
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; | ||
} | ||
const num = parseInt(hex, 16); | ||
@@ -224,2 +210,3 @@ const r = num >> 16; | ||
} | ||
/** | ||
@@ -232,7 +219,6 @@ * Convert HSV coordinate to HSVrad (degree to radian) | ||
*/ | ||
function Hsv2hsvRad([h, s, v]) { | ||
return [h * Math.PI / 180, s, v]; | ||
} | ||
/** | ||
@@ -247,4 +233,2 @@ * Convert HSVrad color to HSV (radian to degree) | ||
*/ | ||
function HsvRad2hsv(hRad, s, v) { | ||
@@ -255,2 +239,3 @@ const precision = 1000000000000; | ||
} | ||
/** | ||
@@ -263,4 +248,2 @@ * Convert HEX to HSVrad | ||
*/ | ||
function Hex2hsvRad(hex) { | ||
@@ -276,2 +259,3 @@ const [r, g, b] = Hex2rgb(hex); | ||
} | ||
/** | ||
@@ -286,4 +270,2 @@ * Convert HSVrad to HEX | ||
*/ | ||
function HsvRad2hex(hRad, s, v) { | ||
@@ -299,2 +281,3 @@ const [h] = HsvRad2hsv(hRad, s, v); | ||
} | ||
/** | ||
@@ -310,4 +293,2 @@ * Convert RGB values to ANSI16 million colors - truecolor | ||
*/ | ||
function rgb2ansi_16m(r, g, b, bg = false) { | ||
@@ -317,2 +298,3 @@ const layer_code = bg ? 48 : 38; | ||
} | ||
/** | ||
@@ -327,4 +309,2 @@ * Convert RGB values to ANSI256 escape code | ||
*/ | ||
function rgb2ansi256Code(red, green, blue) { | ||
@@ -335,12 +315,10 @@ if (red === green && green === blue) { | ||
} | ||
if (red > 248) { | ||
return 231; | ||
} | ||
return Math.round((red - 8) / 247 * 24) + 232; | ||
} | ||
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5); | ||
} | ||
/** | ||
@@ -356,4 +334,2 @@ * Convert RGB values to ANSI256 | ||
*/ | ||
function rgb2ansi_256(r, g, b, bg = false) { | ||
@@ -364,2 +340,3 @@ const layer_code = bg ? 48 : 38; | ||
} | ||
/** | ||
@@ -373,89 +350,67 @@ * Convert ANSI256 code values to ANSI16 | ||
*/ | ||
function ansi_2562ansi_16(code, bg = false) { | ||
let ansi_16_code; | ||
if (code <= 7) { | ||
ansi_16_code = code + 10; | ||
} | ||
if (code >= 8 && code <= 15) { | ||
ansi_16_code = code + 82; | ||
} | ||
if (code === 16) { | ||
ansi_16_code = 0; | ||
} | ||
if (code >= 17 && code <= 19) { | ||
ansi_16_code = 34; | ||
} | ||
if (code >= 20 && code <= 21 || code >= 25 && code <= 27) { | ||
ansi_16_code = 94; | ||
} | ||
if (code >= 22 && code <= 24 || code >= 58 && code <= 60 || code >= 64 && code <= 66 || code >= 94 && code <= 95 || code >= 100 && code <= 102 || code >= 106 && code <= 108 || code >= 130 && code <= 131 || code >= 136 && code <= 138 || code >= 142 && code <= 144 || code >= 148 && code <= 151 || code >= 172 && code <= 174 || code >= 178 && code <= 181 || code >= 184 && code <= 189) { | ||
ansi_16_code = 33; | ||
} | ||
if (code >= 28 && code <= 30 || code >= 34 && code <= 36 || code >= 70 && code <= 72 || code >= 76 && code <= 79 || code >= 112 && code <= 114) { | ||
ansi_16_code = 32; | ||
} | ||
if (code >= 31 && code <= 33 || code >= 37 && code <= 39 || code >= 44 && code <= 45 || code >= 61 && code <= 63 || code >= 67 && code <= 69 || code >= 73 && code <= 75 || code >= 80 && code <= 81 || code >= 103 && code <= 111 || code >= 115 && code <= 117 || code >= 152 && code <= 153) { | ||
ansi_16_code = 36; | ||
} | ||
if (code >= 40 && code <= 43 || code >= 46 && code <= 49 || code >= 82 && code <= 85 || code >= 118 && code <= 120 || code >= 154 && code <= 157) { | ||
ansi_16_code = 92; | ||
} | ||
if (code >= 50 && code <= 51 || code >= 86 && code <= 87 || code >= 121 && code <= 123 || code >= 158 && code <= 159) { | ||
ansi_16_code = 96; | ||
} | ||
if (code >= 52 && code <= 54 || code >= 88 && code <= 90 || code >= 124 && code <= 126 || code >= 166 && code <= 168) { | ||
ansi_16_code = 31; | ||
} | ||
if (code >= 55 && code <= 57 || code >= 91 && code <= 93 || code >= 96 && code <= 99 || code >= 127 && code <= 129 || code >= 132 && code <= 135 || code >= 139 && code <= 141 || code >= 145 && code <= 147 || code >= 169 && code <= 171 || code >= 175 && code <= 177) { | ||
ansi_16_code = 35; | ||
} | ||
if (code >= 160 && code <= 163 || code >= 196 && code <= 199 || code >= 202 && code <= 213) { | ||
ansi_16_code = 91; | ||
} | ||
if (code >= 164 && code <= 165 || code >= 182 && code <= 183 || code >= 200 && code <= 201 || code >= 218 && code <= 219) { | ||
ansi_16_code = 95; | ||
} | ||
if (code >= 190 && code <= 193 || code >= 214 && code <= 217 || code >= 220 && code <= 228) { | ||
ansi_16_code = 93; | ||
} | ||
if (code >= 194 && code <= 195 || code >= 229 && code <= 231 || code >= 253 && code <= 255) { | ||
ansi_16_code = 97; | ||
} | ||
if (code >= 232 && code <= 239) { | ||
ansi_16_code = 30; | ||
} | ||
if (code >= 240 && code <= 246) { | ||
ansi_16_code = 90; | ||
} | ||
if (code >= 247 && code <= 252) { | ||
ansi_16_code = 37; | ||
} | ||
if (bg) { | ||
ansi_16_code = ansi_16_code + 10; | ||
} | ||
return `\u001b[${ansi_16_code}m`; | ||
} | ||
/** | ||
@@ -466,29 +421,22 @@ * Detect the ANSI support for the current terminal taking into account env vars NO_COLOR and FORCE_COLOR | ||
*/ | ||
function get_term_color_support() { | ||
let term_support = supportsColor().level || 3; | ||
if ('NO_COLOR' in process.env) { | ||
term_support = 0; | ||
} | ||
if (process.env['FORCE_COLOR'] === '0') { | ||
term_support = 0; | ||
} | ||
if (process.env['FORCE_COLOR'] === '1') { | ||
term_support = 1; | ||
} | ||
if (process.env['FORCE_COLOR'] === '2') { | ||
term_support = 2; | ||
} | ||
if (process.env['FORCE_COLOR'] === '3') { | ||
term_support = 3; | ||
} | ||
return term_support; | ||
} | ||
/** | ||
@@ -506,4 +454,2 @@ * Abstraction for coloring hex-, keyword- and background-colors | ||
*/ | ||
const Color = (color, bg = false) => { | ||
@@ -528,4 +474,5 @@ const COLORS = { | ||
}; | ||
const support = get_term_color_support(); // bail early if we use system color | ||
const support = get_term_color_support(); | ||
// bail early if we use system color | ||
if (color === 'system' || support === 0) { | ||
@@ -537,9 +484,6 @@ return { | ||
} | ||
const OPTIONS = Options.get; | ||
if (OPTIONS.env === 'node') { | ||
let open; | ||
let close = bg ? '\u001b[49m' : '\u001b[39m'; | ||
switch (color.toLowerCase()) { | ||
@@ -549,75 +493,56 @@ case 'transparent': | ||
break; | ||
case 'black': | ||
open = bg ? '\u001b[40m' : '\u001b[30m'; | ||
break; | ||
case 'red': | ||
open = bg ? '\u001b[41m' : '\u001b[31m'; | ||
break; | ||
case 'green': | ||
open = bg ? '\u001b[42m' : '\u001b[32m'; | ||
break; | ||
case 'yellow': | ||
open = bg ? '\u001b[43m' : '\u001b[33m'; | ||
break; | ||
case 'blue': | ||
open = bg ? '\u001b[44m' : '\u001b[34m'; | ||
break; | ||
case 'magenta': | ||
open = bg ? '\u001b[45m' : '\u001b[35m'; | ||
break; | ||
case 'cyan': | ||
open = bg ? '\u001b[46m' : '\u001b[36m'; | ||
break; | ||
case 'white': | ||
open = bg ? '\u001b[47m' : '\u001b[37m'; | ||
break; | ||
case 'gray': | ||
open = bg ? '\u001b[100m' : '\u001b[90m'; | ||
break; | ||
case 'redbright': | ||
open = bg ? '\u001b[101m' : '\u001b[91m'; | ||
break; | ||
case 'greenbright': | ||
open = bg ? '\u001b[102m' : '\u001b[92m'; | ||
break; | ||
case 'yellowbright': | ||
open = bg ? '\u001b[103m' : '\u001b[93m'; | ||
break; | ||
case 'bluebright': | ||
open = bg ? '\u001b[104m' : '\u001b[94m'; | ||
break; | ||
case 'magentabright': | ||
open = bg ? '\u001b[105m' : '\u001b[95m'; | ||
break; | ||
case 'cyanbright': | ||
open = bg ? '\u001b[106m' : '\u001b[96m'; | ||
break; | ||
case 'whitebright': | ||
open = bg ? '\u001b[107m' : '\u001b[97m'; | ||
break; | ||
case 'candy': | ||
open = ['\u001b[31m', '\u001b[32m', '\u001b[33m', '\u001b[35m', '\u001b[36m', '\u001b[91m', '\u001b[92m', '\u001b[93m', '\u001b[94m', '\u001b[95m', '\u001b[96m'][Math.floor(Math.random() * 11)]; | ||
break; | ||
default: | ||
{ | ||
let hex = color; | ||
if (!HEXTEST.test(color)) { | ||
@@ -629,13 +554,9 @@ return { | ||
} | ||
const rgb = Hex2rgb(hex); | ||
if (support === 1) { | ||
open = ansi_2562ansi_16(rgb2ansi256Code(rgb[0], rgb[1], rgb[2]), bg); | ||
} | ||
if (support === 2) { | ||
open = rgb2ansi_256(rgb[0], rgb[1], rgb[2], bg); | ||
} | ||
if (support === 3) { | ||
@@ -646,3 +567,2 @@ open = rgb2ansi_16m(rgb[0], rgb[1], rgb[2], bg); | ||
} | ||
return { | ||
@@ -660,3 +580,2 @@ open, | ||
color = COLORS[color.toLowerCase()]; | ||
if (!color) { | ||
@@ -669,3 +588,2 @@ return { | ||
} | ||
if (bg) { | ||
@@ -677,3 +595,2 @@ return { | ||
} | ||
return { | ||
@@ -685,3 +602,2 @@ open: `<span style="color:${color}">`, | ||
}; | ||
module.exports = exports = { | ||
@@ -688,0 +604,0 @@ HEXTEST, |
@@ -15,2 +15,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -21,6 +22,6 @@ | ||
} = require('./Debugging.js'); | ||
const { | ||
Color | ||
} = require('./Color.js'); | ||
/** | ||
@@ -35,7 +36,4 @@ * Replace placeholders with color information | ||
*/ | ||
const Colorize = (character, fontColors, optionColors) => { | ||
Debugging.report(`Running Colorize`, 1); | ||
if (character !== undefined) { | ||
@@ -55,5 +53,5 @@ if (fontColors > 1) { | ||
} | ||
} // if only one color is allowed there won't be any color placeholders in the characters | ||
} | ||
// if only one color is allowed there won't be any color placeholders in the characters | ||
if (fontColors === 1) { | ||
@@ -68,8 +66,6 @@ const color = optionColors[0] || 'system'; | ||
} | ||
return character; | ||
}; | ||
module.exports = exports = { | ||
Colorize | ||
}; |
@@ -22,4 +22,6 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; // global defaults | ||
'use strict'; | ||
// global defaults | ||
const CHARS = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '|', '!', '?', '.', '+', '-', '_', '=', '@', '#', '$', '%', '&', '(', ')', '/', ':', ';', ',', ' ', "'", '"']; | ||
@@ -234,5 +236,3 @@ const COLORS = { | ||
}; | ||
const PACKAGE = require('../package.json'); | ||
module.exports = exports = { | ||
@@ -239,0 +239,0 @@ CHARS, |
@@ -15,2 +15,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -21,2 +22,3 @@ | ||
} = require('./Color.js'); | ||
/** | ||
@@ -27,4 +29,2 @@ * DEBUG object for tracking debug mode and level | ||
*/ | ||
const DEBUG = { | ||
@@ -35,20 +35,16 @@ store: { | ||
}, | ||
set enabled(value) { | ||
this.store.enabled = value; | ||
}, | ||
get enabled() { | ||
return this.store.enabled; | ||
}, | ||
set level(value) { | ||
this.store.level = value; | ||
}, | ||
get level() { | ||
return this.store.level; | ||
} | ||
}; | ||
}; | ||
/** | ||
@@ -59,3 +55,2 @@ * Debugging prettiness | ||
*/ | ||
const Debugging = { | ||
@@ -79,3 +74,2 @@ /** | ||
}, | ||
/** | ||
@@ -106,3 +100,2 @@ * Return a message to report starting a process | ||
}, | ||
/** | ||
@@ -109,0 +102,0 @@ * Return a message to report an error |
@@ -15,2 +15,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -21,15 +22,12 @@ | ||
} = require('./constants.js'); | ||
const { | ||
Render | ||
} = require('./Render.js'); | ||
const { | ||
Color | ||
} = require('./Color.js'); | ||
/** | ||
* Display the help generated from our CLIOPTIONS | ||
*/ | ||
const DisplayHelp = () => { | ||
@@ -53,5 +51,4 @@ const { | ||
}; | ||
module.exports = exports = { | ||
DisplayHelp | ||
}; |
@@ -15,2 +15,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -21,13 +22,11 @@ | ||
} = require('./constants.js'); | ||
/** | ||
* Display the version of this package | ||
*/ | ||
const DisplayVersion = () => { | ||
console.log(PACKAGE.version); | ||
}; | ||
module.exports = exports = { | ||
DisplayVersion | ||
}; |
@@ -15,3 +15,5 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
/** | ||
@@ -24,3 +26,2 @@ * Get the position of the first character out of all strings inside an array | ||
*/ | ||
function GetFirstCharacterPosition(lines) { | ||
@@ -30,5 +31,4 @@ const earliest = lines.reduce((prevLine, line) => line.length - line.trimStart().length < prevLine.length - prevLine.trimStart().length && line !== '' ? line : prevLine, lines[0]); | ||
} | ||
module.exports = exports = { | ||
GetFirstCharacterPosition | ||
}; |
@@ -15,9 +15,10 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
const path = require('path'); | ||
const { | ||
Debugging | ||
} = require('./Debugging.js'); | ||
/** | ||
@@ -30,11 +31,9 @@ * Get a selected JSON font-file object | ||
*/ | ||
const GetFont = font => { | ||
Debugging.report(`Running GetFont`, 1); // try loading the font file | ||
Debugging.report(`Running GetFont`, 1); | ||
// try loading the font file | ||
try { | ||
let FONTFACE = require(path.normalize(`../fonts/${font}.json`)); // read font file | ||
Debugging.report(`GetFont: Fontface path selected: "${font}.json"`, 2); | ||
@@ -47,5 +46,4 @@ return FONTFACE; | ||
}; | ||
module.exports = exports = { | ||
GetFont | ||
}; |
@@ -15,3 +15,5 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
/** | ||
@@ -24,7 +26,5 @@ * Return the longest line of an Array | ||
*/ | ||
const GetLongestLine = lines => lines.reduce((longestLine, line) => line.length > longestLine.length && line.length !== 0 ? line : longestLine, ''); | ||
module.exports = exports = { | ||
GetLongestLine | ||
}; |
@@ -22,2 +22,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -28,3 +29,2 @@ | ||
} = require('./GetFirstCharacterPosition.js'); | ||
const { | ||
@@ -37,14 +37,12 @@ Color, | ||
} = require('./Color.js'); | ||
const { | ||
GetLongestLine | ||
} = require('./GetLongestLine.js'); | ||
const { | ||
GRADIENTS | ||
} = require('./constants.js'); | ||
const { | ||
Debugging | ||
} = require('./Debugging.js'); | ||
/** | ||
@@ -60,4 +58,2 @@ * Interpolate a linear path from a number to another number | ||
*/ | ||
function GetLinear(pointA, pointB, n, steps) { | ||
@@ -67,5 +63,5 @@ if (steps === 0) { | ||
} | ||
return pointA + n * ((pointB - pointA) / steps); | ||
} | ||
/** | ||
@@ -81,12 +77,8 @@ * Interpolate a radial path from a number to another number | ||
*/ | ||
function GetTheta(fromTheta, toTheta, n, steps) { | ||
const TAU = 2 * Math.PI; | ||
let longDistance; | ||
if (steps === 0) { | ||
return toTheta; | ||
} | ||
if (fromTheta > toTheta) { | ||
@@ -105,15 +97,12 @@ if (fromTheta - toTheta < Math.PI) { | ||
} | ||
let result = fromTheta + n * (longDistance / steps); | ||
if (result < 0) { | ||
result += TAU; | ||
} | ||
if (result > TAU) { | ||
result -= TAU; | ||
} | ||
return result; | ||
} | ||
/** | ||
@@ -128,4 +117,2 @@ * Generate the most colorful delta between two colors | ||
*/ | ||
function GetGradientColors(fromColor, toColor, steps) { | ||
@@ -135,3 +122,2 @@ const [fromHRad, fromS, fromV] = Hex2hsvRad(fromColor); | ||
const hexColors = []; | ||
for (let n = 0; n < steps; n++) { | ||
@@ -143,5 +129,5 @@ const hRad = GetTheta(fromHRad, toHRad, n, steps - 1); | ||
} | ||
return hexColors; | ||
} | ||
/** | ||
@@ -156,4 +142,2 @@ * Take a bunch of lines and color them in the colors provided | ||
*/ | ||
function PaintLines(lines, colors, firstCharacterPosition) { | ||
@@ -174,2 +158,3 @@ Debugging.report(`Running PaintLines`, 1); | ||
} | ||
/** | ||
@@ -182,4 +167,2 @@ * Make sure a color is hex | ||
*/ | ||
function Color2hex(color) { | ||
@@ -200,2 +183,3 @@ const colorMap = { | ||
} | ||
/** | ||
@@ -209,18 +193,17 @@ * Calculate the gaps between an array of points | ||
*/ | ||
function GetGaps(points, steps) { | ||
// steps per gap | ||
const gapSteps = Math.floor((steps - points.length) / (points.length - 1)); // steps left over to be distributed | ||
const gapSteps = Math.floor((steps - points.length) / (points.length - 1)); | ||
// steps left over to be distributed | ||
const rest = steps - (points.length + gapSteps * (points.length - 1)); | ||
// the gaps array has one less items than our points (cause it's gaps between each of the points) | ||
const gaps = Array(points.length - 1).fill(gapSteps); | ||
const rest = steps - (points.length + gapSteps * (points.length - 1)); // the gaps array has one less items than our points (cause it's gaps between each of the points) | ||
const gaps = Array(points.length - 1).fill(gapSteps); // let's fill in the rest from the right | ||
// let's fill in the rest from the right | ||
for (let i = 0; i < rest; i++) { | ||
gaps[gaps.length - 1 - i]++; | ||
} | ||
return gaps; | ||
} | ||
/** | ||
@@ -235,4 +218,2 @@ * Generate colors between two given colors | ||
*/ | ||
function TransitionBetweenHex(fromHex, toHex, steps) { | ||
@@ -243,3 +224,2 @@ const fromRgb = Hex2rgb(fromHex); | ||
steps++; | ||
for (let n = 1; n < steps; n++) { | ||
@@ -251,5 +231,5 @@ const red = GetLinear(fromRgb[0], toRgb[0], n, steps); | ||
} | ||
return hexColors; | ||
} | ||
/** | ||
@@ -264,7 +244,4 @@ * Generate n colors between x colors | ||
*/ | ||
function Transition(colors, steps, gradients = GRADIENTS) { | ||
let hexColors = []; | ||
if (colors.length === 1) { | ||
@@ -275,12 +252,8 @@ colors = gradients[colors[0].toLowerCase()]; | ||
} | ||
const gaps = GetGaps(colors, steps); | ||
if (steps <= 1) { | ||
return [colors[colors.length - 1]]; | ||
} | ||
for (let i = 0; i < colors.length; i++) { | ||
const gap = gaps[i - 1]; | ||
if (colors[i - 1]) { | ||
@@ -290,3 +263,2 @@ const gapColors = TransitionBetweenHex(colors[i - 1], colors[i], gap); | ||
} | ||
if (gap !== -1) { | ||
@@ -296,5 +268,5 @@ hexColors.push(colors[i]); | ||
} | ||
return hexColors; | ||
} | ||
/** | ||
@@ -314,4 +286,2 @@ * Paint finished output in a gradient | ||
*/ | ||
function PaintGradient({ | ||
@@ -328,3 +298,2 @@ output, | ||
let newOutput = []; | ||
if (transitionGradient) { | ||
@@ -335,6 +304,4 @@ Debugging.report(`Gradient transition with colors: ${JSON.stringify(gradient)}`, 2); | ||
} | ||
let firstCharacterPosition = GetFirstCharacterPosition(output); | ||
let longestLine = GetLongestLine(output).length; | ||
for (let i = 0; i < lines; i++) { | ||
@@ -344,3 +311,2 @@ const start = i * (fontLines + lineHeight); | ||
const thisLine = output.slice(start, end); | ||
if (independentGradient) { | ||
@@ -350,3 +316,2 @@ firstCharacterPosition = GetFirstCharacterPosition(thisLine); | ||
} | ||
const colorsNeeded = longestLine - firstCharacterPosition; | ||
@@ -358,6 +323,4 @@ const linesInbetween = i === 0 ? [] : Array(lineHeight).fill(''); | ||
} | ||
return newOutput; | ||
} | ||
module.exports = exports = { | ||
@@ -364,0 +327,0 @@ GetLinear, |
@@ -15,2 +15,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -21,34 +22,27 @@ | ||
} = require('./DisplayVersion.js'); | ||
const { | ||
DisplayHelp | ||
} = require('./DisplayHelp.js'); | ||
const { | ||
CLIOPTIONS | ||
} = require('./constants.js'); | ||
const { | ||
Debugging | ||
} = require('./Debugging.js'); | ||
const { | ||
ParseArgs | ||
} = require('./ParseArgs.js'); | ||
const { | ||
Render | ||
} = require('./Render.js'); | ||
const { | ||
Color | ||
} = require('./Color.js'); | ||
const { | ||
Log | ||
} = require('./Log.js'); | ||
const { | ||
Say | ||
} = require('./Say.js'); | ||
/** | ||
@@ -60,8 +54,5 @@ * Run cli commands | ||
*/ | ||
const Cli = (inputOptions = CLIOPTIONS, inputArgs = process.argv) => { | ||
const args = ParseArgs(inputOptions, inputArgs); | ||
Debugging.report(`OPTIONS:\n` + ` CFonts.say("${args.text}", {\n` + ` font: "${args.font}",\n` + ` align: "${args.align}",\n` + ` colors: ${args.colors ? JSON.stringify(args.colors.split(',')) : []},\n` + ` background: "${args.background}",\n` + ` letterSpacing: ${args['letter-spacing']},\n` + ` lineHeight: ${args['line-height']},\n` + ` space: ${!args.spaceless},\n` + ` maxLength: ${args['max-length']},\n` + ` gradient: ${args.gradient},\n` + ` independentGradient: ${args['independent-gradient']},\n` + ` transitionGradient: ${args['transition-gradient']},\n` + ` env: ${args.env},\n` + ` }, ${args.debug}, ${args.debugLevel} );`, 3, args.debug, args.debugLevel); | ||
if (args.help) { | ||
@@ -71,3 +62,2 @@ DisplayHelp(); | ||
} | ||
if (args.version) { | ||
@@ -77,3 +67,2 @@ DisplayVersion(); | ||
} | ||
if (!args.text) { | ||
@@ -87,3 +76,2 @@ const { | ||
} | ||
Say(args.text, { | ||
@@ -104,3 +92,2 @@ font: args.font, | ||
}; | ||
module.exports = exports = { | ||
@@ -107,0 +94,0 @@ render: Render, |
@@ -15,2 +15,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -21,2 +22,3 @@ | ||
} = require('./Color.js'); | ||
/** | ||
@@ -27,4 +29,2 @@ * Logging prettiness | ||
*/ | ||
const Log = { | ||
@@ -38,3 +38,2 @@ /** | ||
text = text.replace(/(?:\r\n|\r|\n)/g, '\n '); // indent each line | ||
const { | ||
@@ -41,0 +40,0 @@ open, |
@@ -15,2 +15,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -23,2 +24,3 @@ | ||
} = require('./constants.js'); | ||
/** | ||
@@ -29,7 +31,4 @@ * The options store with getter and setter methods | ||
*/ | ||
const Options = { | ||
store: {}, | ||
reset() { | ||
@@ -50,3 +49,4 @@ const defaults = { | ||
}; | ||
this.store = { ...defaults | ||
this.store = { | ||
...defaults | ||
}; // cloning | ||
@@ -63,3 +63,2 @@ }, | ||
}, | ||
/** | ||
@@ -118,3 +117,2 @@ * Merge settings into our options object | ||
} | ||
}; | ||
@@ -121,0 +119,0 @@ module.exports = exports = { |
@@ -15,2 +15,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -21,10 +22,9 @@ | ||
} = require('./AddShortcuts.js'); | ||
const { | ||
CLIOPTIONS | ||
} = require('./constants.js'); | ||
const { | ||
Debugging | ||
} = require('./Debugging.js'); | ||
/** | ||
@@ -38,9 +38,8 @@ * Parse cli arguments into a nice object | ||
*/ | ||
const ParseArgs = (inputOptions = CLIOPTIONS, inputArgs = process.argv) => { | ||
const parsedArgs = { | ||
text: inputArgs[2] | ||
}; // create defaults | ||
}; | ||
// create defaults | ||
Object.keys(inputOptions).forEach(option => { | ||
@@ -54,19 +53,13 @@ const name = option.replace('--', ''); | ||
const version_options = options['-v']; | ||
if (inputArgs[2] === version_options._name || inputArgs[2] === version_options.short || inputArgs[2] === version_options.fallback_shortcut) { | ||
parsedArgs.version = true; | ||
} | ||
const help_options = options['-h']; | ||
if (inputArgs[2] === help_options._name || inputArgs[2] === help_options.short || inputArgs[2] === help_options.fallback_shortcut) { | ||
parsedArgs.help = true; | ||
} | ||
for (let index = 0; args.length > index; index++) { | ||
const option = options[args[index]]; | ||
if (option) { | ||
const name = option._name.replace('--', ''); | ||
if (option.options !== undefined) { | ||
@@ -83,8 +76,6 @@ index++; | ||
} | ||
return parsedArgs; | ||
}; | ||
module.exports = exports = { | ||
ParseArgs | ||
}; |
@@ -15,2 +15,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -21,3 +22,2 @@ | ||
} = require('./AddLetterSpacing.js'); | ||
const { | ||
@@ -27,54 +27,42 @@ Debugging, | ||
} = require('./Debugging.js'); | ||
const { | ||
PaintGradient | ||
} = require('./Gradient.js'); | ||
const { | ||
CharLength | ||
} = require('./CharLength.js'); | ||
const { | ||
CheckInput | ||
} = require('./CheckInput.js'); | ||
const { | ||
CleanInput | ||
} = require('./CleanInput.js'); | ||
const { | ||
AlignText | ||
} = require('./AlignText.js'); | ||
const { | ||
AddLine | ||
} = require('./AddLine.js'); | ||
const { | ||
AddChar | ||
} = require('./AddChar.js'); | ||
const { | ||
Options | ||
} = require('./Options.js'); | ||
const { | ||
GetFont | ||
} = require('./GetFont.js'); | ||
const { | ||
CHARS | ||
} = require('./constants.js'); | ||
const { | ||
Color | ||
} = require('./Color.js'); | ||
const { | ||
Size | ||
} = require('./Size.js'); | ||
const { | ||
Log | ||
} = require('./Log.js'); | ||
/** | ||
@@ -99,4 +87,2 @@ * Main method to get the ANSI output for a string | ||
*/ | ||
const Render = (input, SETTINGS = {}, debug = DEBUG.enabled, debuglevel = DEBUG.level, size = Size) => { | ||
@@ -111,45 +97,37 @@ Debugging.report(`Running render`, 1); | ||
let output = []; // for output where each line is an output line | ||
let lines = 0; // for counting each line | ||
let FONTFACE = {}; // scoping the fontface object higher for fonts with just one color | ||
const _isGoodHuman = CheckInput(INPUT, OPTIONS.font, OPTIONS.colors, OPTIONS.background, OPTIONS.align, OPTIONS.gradient, OPTIONS.transitionGradient, OPTIONS.env); | ||
if (!_isGoodHuman.pass) { | ||
Log.error(_isGoodHuman.message); | ||
return false; | ||
} // the gradient option supersedes the color options | ||
} | ||
// the gradient option supersedes the color options | ||
if (OPTIONS.gradient) { | ||
OPTIONS.colors = []; | ||
} // display an overview of options if debug flag is enabled | ||
} | ||
// display an overview of options if debug flag is enabled | ||
if (DEBUG.enabled) { | ||
let outOption = `OPTIONS:\n Text: ${INPUT}`; | ||
for (let key in OPTIONS) { | ||
outOption += `\n Options.${key}: ${OPTIONS[key]}`; | ||
} | ||
Debugging.report(outOption, 3); | ||
} | ||
if (OPTIONS.env === 'browser') { | ||
size = { ...size | ||
size = { | ||
...size | ||
}; // we clone so we don't make changes to this object across multiple instances | ||
size.width = OPTIONS.maxLength === 0 ? 999999999999 : OPTIONS.maxLength; | ||
} | ||
FONTFACE = GetFont(OPTIONS.font); | ||
if (!FONTFACE) { | ||
Log.error(`Font file for the font "${OPTIONS.font}" could not be found.\nTry reinstalling this package.`); | ||
return false; | ||
} // setting the letterspacing preference from font face if there is no user overwrite | ||
} | ||
// setting the letterspacing preference from font face if there is no user overwrite | ||
if (SETTINGS.letterSpacing === undefined) { | ||
@@ -168,31 +146,23 @@ Debugging.report(`Looking up letter spacing from font face`, 1); | ||
} | ||
let lineLength = CharLength(FONTFACE.buffer, FONTFACE.lines, OPTIONS); // count each output character per line and start with the buffer | ||
let maxChars = 0; // count each character we print for maxLength option | ||
output = AddLine([], FONTFACE.lines, FONTFACE.buffer, OPTIONS.lineHeight); // create first lines with buffer | ||
lines++; | ||
for (let i = 0; i < INPUT.length; i++) { | ||
// iterate through the message | ||
let CHAR = INPUT.charAt(i).toUpperCase(); // the current character we convert, only upper case is supported at this time | ||
let lastLineLength = lineLength; // we need the lineLength for alignment before we look up if the next char fits | ||
Debugging.report(`Character found in font: "${CHAR}"`, 2); | ||
if (CHAR !== `|`) { | ||
// what will the line length be if we add the next char? | ||
lineLength += CharLength(FONTFACE.chars[CHAR], FONTFACE.lines, OPTIONS); // get the length of this character | ||
lineLength += CharLength(FONTFACE.letterspace, FONTFACE.lines, OPTIONS) * OPTIONS.letterSpacing; // new line, new line length | ||
} // jump to next line after OPTIONS.maxLength characters or when line break is found or the console windows would have ran out of space | ||
} | ||
// jump to next line after OPTIONS.maxLength characters or when line break is found or the console windows would have ran out of space | ||
if (maxChars >= OPTIONS.maxLength && OPTIONS.maxLength != 0 || CHAR === `|` || lineLength > size.width) { | ||
lines++; | ||
Debugging.report(`NEWLINE: maxChars: ${maxChars}, ` + `OPTIONS.maxLength: ${OPTIONS.maxLength}, ` + `CHAR: ${CHAR}, ` + `lineLength: ${lineLength}, ` + `Size.width: ${size.width} `, 2); | ||
if (OPTIONS.env === 'node') { | ||
@@ -203,3 +173,2 @@ output = AlignText(output, lastLineLength, FONTFACE.lines, OPTIONS.align, size); // calculate alignment based on lineLength | ||
lineLength += CharLength(FONTFACE.letterspace, FONTFACE.lines, OPTIONS) * OPTIONS.letterSpacing; // each new line starts with letter spacing | ||
lineLength = CharLength(FONTFACE.buffer, FONTFACE.lines, OPTIONS); // new line: new line length | ||
@@ -210,3 +179,2 @@ | ||
lineLength += CharLength(FONTFACE.letterspace, FONTFACE.lines, OPTIONS) * OPTIONS.letterSpacing; // add letter spacing at the end | ||
lineLength += CharLength(FONTFACE.chars[CHAR], FONTFACE.lines, OPTIONS); // get the length of this character | ||
@@ -222,6 +190,4 @@ } | ||
Debugging.report(`lineLength at: "${lineLength}"`, 2); | ||
if (CHAR !== `|`) { | ||
maxChars++; // counting all printed characters | ||
output = AddLetterSpacing(output, FONTFACE.lines, FONTFACE.letterspace, FONTFACE.colors, OPTIONS.colors, OPTIONS.letterSpacing); | ||
@@ -247,3 +213,2 @@ output = AddChar(CHAR, output, FONTFACE.lines, FONTFACE.chars, FONTFACE.colors, OPTIONS.colors); // add new character | ||
} | ||
if (OPTIONS.space) { | ||
@@ -260,3 +225,2 @@ // add space | ||
} | ||
if (OPTIONS.background !== 'transparent' && OPTIONS.env === 'node') { | ||
@@ -270,5 +234,3 @@ const { | ||
} | ||
let write = output.join(OPTIONS.env === 'node' ? `\n` : '<br>\n'); | ||
if (OPTIONS.env === 'browser') { | ||
@@ -280,3 +242,2 @@ const { | ||
} | ||
return { | ||
@@ -289,5 +250,4 @@ string: write, | ||
}; | ||
module.exports = exports = { | ||
Render | ||
}; |
@@ -15,2 +15,3 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
@@ -22,10 +23,9 @@ | ||
} = require('./Debugging.js'); | ||
const { | ||
Render | ||
} = require('./Render.js'); | ||
const { | ||
Size | ||
} = require('./Size.js'); | ||
/** | ||
@@ -42,4 +42,2 @@ * Print to console | ||
*/ | ||
const Say = (INPUT, SETTINGS = {}, debug = DEBUG.enabled, debuglevel = DEBUG.level, size = Size) => { | ||
@@ -50,3 +48,2 @@ Debugging.report(`Running say`, 1); | ||
const write = Render(INPUT, SETTINGS, debug, debuglevel, size); | ||
if (write) { | ||
@@ -53,0 +50,0 @@ console.log(write.string); // write out |
@@ -15,5 +15,7 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
const WinSize = require('window-size'); | ||
/** | ||
@@ -24,4 +26,2 @@ * Abstraction for windows size | ||
*/ | ||
const Size = { | ||
@@ -28,0 +28,0 @@ width: WinSize ? WinSize.width > 0 ? WinSize.width : 80 : 80, |
@@ -15,3 +15,5 @@ /*************************************************************************************************************************************************************** | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
/** | ||
@@ -26,7 +28,5 @@ * Upper case the first character of an input string. | ||
*/ | ||
const UpperCaseFirst = input => typeof input === 'string' ? input.charAt(0).toUpperCase() + input.substr(1) : input; | ||
module.exports = exports = { | ||
UpperCaseFirst | ||
}; |
{ | ||
"name": "cfonts", | ||
"description": "Sexy ANSI fonts for the console", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"homepage": "https://github.com/dominikwilkowski/cfonts", | ||
@@ -45,12 +45,12 @@ "author": { | ||
"devDependencies": { | ||
"@babel/cli": "^7.17.6", | ||
"@babel/core": "^7.17.8", | ||
"@babel/preset-env": "^7.16.11", | ||
"@babel/cli": "^7.21.0", | ||
"@babel/core": "^7.21.3", | ||
"@babel/preset-env": "^7.20.2", | ||
"@types/node": "latest", | ||
"coveralls": "^3.1.1", | ||
"eslint": "^8.12.0", | ||
"jest-cli": "^27.5.1", | ||
"eslint": "^8.36.0", | ||
"jest-cli": "^27", | ||
"onchange": "^7.1.0", | ||
"prettier": "^2.6.2", | ||
"typescript": "^4.6.3" | ||
"prettier": "^2.8.7", | ||
"typescript": "^5.0.2" | ||
}, | ||
@@ -119,3 +119,3 @@ "peerDependencies": {}, | ||
"files": [ | ||
"lib/*.js", | ||
"lib/*", | ||
"bin/*", | ||
@@ -125,2 +125,3 @@ "fonts/*" | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"bin": { | ||
@@ -127,0 +128,0 @@ "cfonts": "./bin/index.js" |
@@ -164,2 +164,3 @@ ```sh | ||
* 3.2.0 - Added TS type to the published npm package | ||
* 3.1.1 - Fixed #58 gradient color bug, added `gray` to gradient colors | ||
@@ -166,0 +167,0 @@ * 3.1.0 - Added support for -V flag fallback |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
295510
68
9469
235
6