stringify-tree
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -12,3 +12,3 @@ import flatten = require("lodash.flatten"); | ||
*/ | ||
export function stringifyTree<T>(tn: T, nameFn: (t: T) => string, childrenFn: (t: T) => T[]): string { | ||
export function stringifyTree<T>(tn: T, nameFn: (t: T) => string, childrenFn: (t: T) => T[] | null): string { | ||
@@ -15,0 +15,0 @@ function prefixChild(strs: string[], last: boolean): string[] { |
{ | ||
"name": "stringify-tree", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Turn a tree structure into an ascii tree", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -139,1 +139,16 @@ import assert from "assert"; | ||
}); | ||
describe("compatibility with null child arrays", () => { | ||
it("prints one tree", () => { | ||
type Tree = { | ||
name: string, | ||
children: [] | null | ||
} | ||
const tree = { | ||
name: "hi", children: null, | ||
}; | ||
const result = stringifyTree(tree, t => t.name, t => t.children); | ||
console.log("tree:\n" + result); | ||
assert.deepEqual(result, "─ hi"); | ||
}); | ||
}) |
26452
14
392