UNPKG

node-ansi-logger

Version:

Enhanced Ansi Color Logging and Stringify for Node.js in type script

76 lines 3.42 kB
/** * This file contains the stringify functions. * * @file stringify.ts * @author Luca Liguori * @created 2023-07-23 * @version 1.4.2 * @license Apache-2.0 * * Copyright 2024, 2025, 2026 Luca Liguori. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Stringify the payload as a JSON string with no colors. * * @param {object} payload - The object to stringify. * @returns {string} A JSON string representation of the payload. */ export declare function payloadStringify(payload: object): string; /** * Stringify the payload as a JSON string with colors. * * @param {object} payload - The object to stringify. * @returns {string} A colored JSON string representation of the payload. */ export declare function colorStringify(payload: object): string; /** * Stringify the payload for history logging with specific colors. * * @param {object} payload - The object to stringify. * @returns {string} A colored JSON string representation of the payload for history. */ export declare function historyStringify(payload: object): string; /** * Stringify the payload for MQTT with specific colors. * * @param {object} payload - The object to stringify. * @returns {string} A colored JSON string representation of the payload for MQTT. */ export declare function mqttStringify(payload: object): string; /** * Stringify the payload for debugging with specific colors. * * @param {object} payload - The object to stringify. * @returns {string} A colored JSON string representation of the payload for debugging. */ export declare function debugStringify(payload: object): string; /** * Stringify the payload with customizable colors and quotes. * * @param {object} payload - The object to stringify. * @param {boolean} enableColors - Whether to enable colors in the output. * @param {number} colorPayload - Color for the payload (default: 252). * @param {number} colorKey - Color for the keys (default: 250). * @param {number} colorString - Color for string values (default: 35). * @param {number} colorNumber - Color for number values (default: 220). * @param {number} colorBoolean - Color for boolean values (default: 159). * @param {number} colorUndefined - Color for undefined values (default: 1). * @param {string} keyQuote - Quote character for keys (default: ''). * @param {string} stringQuote - Quote character for string values (default: "'"). * @param {Set<object>} seenObjects - A set to track already seen objects to prevent circular references. * @returns {string} A string representation of the payload with colors and quotes. */ export declare function stringify(payload: object, enableColors?: boolean, colorPayload?: number, colorKey?: number, colorString?: number, colorNumber?: number, colorBoolean?: number, colorUndefined?: number, keyQuote?: string, stringQuote?: string, seenObjects?: Set<object>): string; //# sourceMappingURL=stringify.d.ts.map