<< All versions
Skill v1.0.0
currentLLM-judged scan90/100senrecep/tsentials/tsentials-tree
──Details
PublishedOctober 17, 2026 at 05:12 AM
Content Hashsha256:8237f04c5eda3ac7...
Git SHA6d0b493b3193
──Files
Files (1 file, 1.3 KB)
SKILL.md1.3 KBactive
SKILL.md · 46 lines · 1.3 KB
version: "1.0.0"
tsentials/tree — Skill
Use when modelling recursive hierarchies: categories, comments, org charts.
API
typescript
import { Tree } from 'tsentials/tree';import type { Tree as TreeType } from 'tsentials/tree'; // interface: { value: T; forest: ReadonlyArray<Tree<T>> }// Constructionconst t = Tree.of('root', [Tree.of('a', [Tree.leaf('a1')]),Tree.leaf('b'),]);// QueryTree.root(t); // 'root' — get root valueTree.children(t); // immediate child Tree nodesTree.size(t); // total nodesTree.isLeaf(t); // has no children?Tree.find(t, v => v === 'a1');Tree.findAll(t, v => v.startsWith('a'));// TransformTree.map(t, v => v.toUpperCase());Tree.filter(t, v => v !== 'b');Tree.toArray(t); // pre-order flattenTree.toArrayWithDepth(t); // [{ value: 'root', depth: 0 }, { value: 'a', depth: 1 }, ...]// FoldTree.fold(t, (value, children) => value + children.reduce((a, b) => a + b, 0));// Pretty printTree.drawTree(t); // uses String() by defaultTree.drawTree(t, v => v.toUpperCase()); // custom show function
Patterns
- Use
Treefor any nested structure where parent-child relationships matter. - Use
foldfor recursive aggregation (sums, validation, rendering).