UNPKG

jsm-treeify

Version:

A library to display JavaScript objects as colorized, tree-like structures in the console.

37 lines (36 loc) 1.61 kB
export type Options = { maxDepth?: number; showArrayIndices?: boolean; sortKeys?: boolean; maxObjectItems?: number; prefix?: string; isLast?: boolean; isRoot?: boolean; }; /** * Converts a Buffer to string if its length is less than specified limit * @param buffer - The buffer to convert * @param encoding - The encoding to use for conversion (default: 'hex') * @param maxLength - Maximum allowed length (default: 256) * @returns The string representation of the buffer, or null if buffer is too large */ export declare function bufferToStringIfSmall(buffer: Buffer, encoding?: BufferEncoding, maxLength?: number): string | null; /** * Sanitizes an object by removing circular references and handling edge cases * @param obj - The object to sanitize * @param maxDepth - Maximum depth to traverse (prevents infinite recursion) * @returns Sanitized object safe for JSON operations */ export declare function sanitize(obj: any, maxDepth?: number, maxObjectItems?: number): any; /** * Transforms an object into a colored tree-like string representation. * * @param obj - The object to transform. * @param prefix - The prefix string for the current level (used for indentation). * @param isLast - Boolean indicating if the current element is the last in its level. * @param isRoot - Boolean indicating if the current element the root element. * @param options - Optional configuration for tree generation. * * @returns An array of strings representing the lines of the colored tree. */ export default function colorizeTree(obj: any, options?: Options): string[];