function applyGradient(str, gradient, opts) { const options = validateOptions(opts); const colorsCount = Math.max(str.replace(forbiddenChars, '').length, gradient.stops.length); const colors = getColors(gradient, options, colorsCount); let result = ''; for (const s of str) { result += s.match(forbiddenChars) ? s : chalk.hex(colors.shift().toHex())(s); } return result; }
Object.keys(parametersList).forEach(key => { log( chalk.default( ` ${chalk.hex("#7159C1").bold(key)}: ${parametersList[key]}` ) ); });
_getPrefix() { return chalk.hex(this._prefixColor)(this.name.padStart(longestNameLength)); }
function multilineGradient(str, gradient, opts) { const options = validateOptions(opts); const lines = str.split('\n'); const maxLength = Math.max.apply(null, lines.map(l => l.length).concat([gradient.stops.length])); const colors = getColors(gradient, options, maxLength); const results = []; for (const line of lines) { const lineColors = colors.slice(0); let lineResult = ''; for (const l of line) { lineResult += chalk.hex(lineColors.shift().toHex())(l); } results.push(lineResult); } return results.join('\n'); }
const createNormalizeValue = ( minValue, maxValue, chartLength, colors, valueFormatter ) => (value, index) => { const normalizedValue = Math.min(value.value - minValue, maxValue - minValue); const lineLength = normalizedValue / (maxValue - minValue) * chartLength; const color = value.color ? value.color : colors[index]; const chartBar = normalBarBuilder(lineLength, color); return { lineLength, normalizedValue, color, chartBar, rawValue: value.value, formattedValue: valueFormatter(value.value), label: value.label || `#${index + 1}`, coloredChartBar: typeof chalk[color] === 'function' ? chalk[color](chartBar) : chalk.hex(color)(chartBar), }; }
process.exit(1); console.log(chalk.hex('#1890FF')('prettier success!')); }); });
colorCell(value) { if (!value) return value; const colorMap = { '2': '#03a9f4', '4': '#4caf50', '8': '#009688', '16': '#ffc107', '32': '#ff5722', '64': '#f44336', '128': '#e91e63', '256': '#9c27b0', '512': '#3f51b5', '1024': '#fbd324', '2048': '#00bcd4', } return chalk.hex([colorMap[value]])(value); }
typeof chalk[value.color] === 'function' ? chalk[value.color](SYMBOLS.Full) : chalk.hex(value.color)(SYMBOLS.Full);