jsm-treeify
Version:
A library to display JavaScript objects as colorized, tree-like structures in the console.
26 lines (25 loc) • 1.1 kB
TypeScript
interface ColorizeOptions {
maxDepth?: number;
showArrayIndices?: boolean;
sortKeys?: boolean;
}
/**
* 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): 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, prefix?: string, isLast?: boolean, isRoot?: boolean, options?: ColorizeOptions): string[];
export {};