"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.colored = exports.setMode = void 0; const chalk_1 = __importDefault(require("chalk")); let mode = 'chalk'; function setMode(newMode) { mode = newMode; } exports.setMode = setMode; function withLevels(levels, strategy) { const fn = str => strategy(levels, str); Object.assign(fn, generateColoredBody(fn, levels, strategy)); return fn; } const allColors = [ 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'gray', 'grey', 'blackBright', 'redBright', 'greenBright', 'yellowBright', 'blueBright', 'magentaBright', 'cyanBright', 'whiteBright', 'italic', 'bold', 'underline', ]; function generateColoredBody(wrapper, levels, strategy) { const c = allColors.reduce((acc, curr) => { Object.defineProperty(acc, curr, { get() { const x = withLevels([...levels, curr], strategy); return x; }, }); return acc; }, wrapper); return c; } const chalked = generateColoredBody({}, [], (levels, str) => { const color = levels.reduce((c, curr) => c[curr], chalk_1.default); return color(str); }); const tagged = generateColoredBody({}, [], (levels, str) => { const [start, end] = levels.reduce((acc, curr) => { acc[0] += `<${curr}>`; acc[1] = `${acc[1]}`; return acc; }, ['', '']); return `${start}${str}${end}`; }); const disabled = generateColoredBody({}, [], (_levels, str) => str); function colored() { if (mode === 'chalk') return chalked; if (mode === 'disabled') return disabled; return tagged; } exports.colored = colored; setMode('tags'); console.log(colored().red.bold('hello')); setMode('chalk'); console.log(colored().red.bold('hello')); //# sourceMappingURL=chalk.js.map