first commit

This commit is contained in:
Stefan Hacker
2026-04-03 09:38:48 +02:00
commit 37ad745546
47450 changed files with 3120798 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
export type * from './types';
export * from './printTree';
export * from './printBinary';
export * from './printJson';
+6
View File
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./printTree"), exports);
tslib_1.__exportStar(require("./printBinary"), exports);
tslib_1.__exportStar(require("./printJson"), exports);
+2
View File
@@ -0,0 +1,2 @@
import type { PrintChild } from './types';
export declare const printBinary: (tab: string | undefined, children: [left?: null | PrintChild, right?: null | PrintChild]) => string;
+13
View File
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.printBinary = void 0;
const printBinary = (tab = '', children) => {
const left = children[0], right = children[1];
let str = '';
if (left)
str += '\n' + tab + '← ' + left(tab + ' ');
if (right)
str += '\n' + tab + '→ ' + right(tab + ' ');
return str;
};
exports.printBinary = printBinary;
+1
View File
@@ -0,0 +1 @@
export declare const printJson: (tab: string | undefined, json: unknown, space?: number | string) => string;
+5
View File
@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.printJson = void 0;
const printJson = (tab = '', json, space = 2) => (JSON.stringify(json, null, space) || 'nil').split('\n').join('\n' + tab);
exports.printJson = printJson;
+2
View File
@@ -0,0 +1,2 @@
import type { PrintChild } from './types';
export declare const printTree: (tab: string | undefined, children: (PrintChild | null)[]) => string;
+21
View File
@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.printTree = void 0;
const printTree = (tab = '', children) => {
let str = '';
let last = children.length - 1;
for (; last >= 0; last--)
if (children[last])
break;
for (let i = 0; i <= last; i++) {
const fn = children[i];
if (!fn)
continue;
const isLast = i === last;
const child = fn(tab + (isLast ? ' ' : '│') + ' ');
const branch = child ? (isLast ? '└─' : '├─') : '│';
str += '\n' + tab + branch + (child ? ' ' + child : '');
}
return str;
};
exports.printTree = printTree;
+4
View File
@@ -0,0 +1,4 @@
export interface Printable {
toString(tab?: string): string;
}
export type PrintChild = (tab: string) => string;
+2
View File
@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });