···149149150150## Input Format
151151152152+> **Disclaimer:**
153153+> The exported `TreeInput` type (`Array<string | TreeInput>`) is intentionally flexible to support dynamic and programmatic tree construction. However, TypeScript cannot enforce at the type level that the first element is a string. This requirement is checked at runtime by the `treeify` function, which will throw an error if the first element is not a string. Please ensure your input arrays follow this convention.
154154+152155The `treeify` function accepts arrays with the following structure:
1531561541571. First element must be a string (the root node)
+10-10
src/index.ts
···11/**
22- * Represents a node in the tree structure.
33- * Can be either a string (a leaf node) or an array of TreeNodes (a branch with children).
22+ * The strict tree input format. Must start with a string.
33+ * This type is exported for testing purposes and advanced usage.
44 */
55-type TreeNode = string | TreeNode[]
55+export type TreeInput = Array<string | TreeInput>
6677/**
88- * The strict tree input format. Must start with a string.
99- * This type is exported for testing purposes and advanced usage.
88+ * Represents a node in the tree structure.
99+ * Can be either a string (a leaf node) or an array of TreeNodes (a branch with children).
1010 */
1111-export type TreeInput = [string, ...Array<string | TreeNode[]>] | string[]
1111+type TreeNode = string | TreeNode[]
12121313/**
1414 * Flexible input type that accepts any array.
···1616 */
1717type FlexibleTreeInput = readonly (string | unknown[])[]
18181919-type TreeChars = {
1919+/**
2020+ * ASCII characters used to render the tree.
2121+ */
2222+export type TreeChars = {
2023 branch: string
2124 lastBranch: string
2225 pipe: string
2326 space: string
2427}
25282626-/**
2727- * @description ASCII characters used to render the tree.
2828- */
2929const DEFAULT_CHARS: TreeChars = {
3030 branch: '├─ ',
3131 lastBranch: '└─ ',