UNPKG

sonic-forest

Version:

High-performance (binary) tree and sorted map implementation (AVL, Splay, Radix, Red-Black)

16 lines (15 loc) 605 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.print = void 0; const printBinary_1 = require("../print/printBinary"); const stringify = JSON.stringify; const print = (node, tab = '') => { if (!node) return '∅'; const { l, r, k, v } = node; const content = k !== undefined ? ` { ${stringify(k)} = ${stringify(v)} }` : ''; return (node.constructor.name + content + (0, printBinary_1.printBinary)(tab, [l ? (tab) => (0, exports.print)(l, tab) : null, r ? (tab) => (0, exports.print)(r, tab) : null])); }; exports.print = print;