tiny-essentials
Version:
Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.
62 lines • 2.12 kB
text/typescript
export default ColorSafeStringify;
/**
* Represents a mapping of color keys to ANSI escape codes.
*/
export type ColorsList = Record<string, string>;
/**
* @typedef {Record<string, string>} ColorsList
* Represents a mapping of color keys to ANSI escape codes.
*/
declare class ColorSafeStringify {
/**
* Preset collections (internal and user-defined).
* @type {Record<string, ColorsList>}
* @static
*/
static "__#private@#PRESETS": Record<string, ColorsList>;
/**
* Constructs a new instance with an optional base preset or custom override.
* @param {ColorsList} [defaultColors] - Optional override for the default color scheme.
*/
constructor(defaultColors?: ColorsList);
/**
* Colorizes a JSON string using the active or optionally overridden color set.
* @param {string} json - The JSON string to format.
* @param {ColorsList} [customColors] - Optional temporary color override.
* @returns {string}
*/
colorize(json: string, customColors?: ColorsList): string;
/**
* Returns the currently active color scheme.
* @returns {ColorsList}
*/
getColors(): ColorsList;
/**
* Updates the current color scheme with a partial override.
* @param {Partial<ColorsList>} newColors
*/
updateColors(newColors: Partial<ColorsList>): void;
/**
* Resets the current color scheme to the default preset.
*/
resetColors(): void;
/**
* Loads a color preset by name.
* @param {string} presetName - Name of the preset to load.
* @throws Will throw if the preset doesn't exist.
*/
loadColorPreset(presetName: string): void;
/**
* Saves a new custom color preset.
* @param {string} name - Name of the new preset.
* @param {ColorsList} colors - ANSI color map to save.
*/
saveColorPreset(name: string, colors: ColorsList): void;
/**
* Returns a list of all available color preset names.
* @returns {string[]}
*/
getAvailablePresets(): string[];
#private;
}
//# sourceMappingURL=ColorSafeStringify.d.mts.map