fast-tree-builder 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://npmjs.org/package/fast-tree-builder)
|
|
5
5
|
[](https://github.com/lionel87/fast-tree-builder/actions/workflows/build.yaml)
|
|
6
6
|
[](https://coveralls.io/github/lionel87/fast-tree-builder?branch=master)
|
|
7
|
-

|
|
8
8
|
|
|
9
9
|
`fast-tree-builder` is a utility for easy tree building from iterable collections, enabling safe and predictable access to hierarchical data. It supports highly customizable input and output shapes.
|
|
10
10
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
- You have a list of items,
|
|
15
15
|
- each item is identifiable by a unique id,
|
|
16
|
-
- the items are
|
|
16
|
+
- the items are connectable via a *parent id* OR a list of *child ids*.
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
## Features
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
- **Multi-Root Support** – Handles disjoint trees naturally.
|
|
29
29
|
- **Arbitary Node Access** – Returns a `Map` that allows constant-time access to any node.
|
|
30
30
|
- **Tree Validation** – Detects cycles or nodes reachable through multiple paths.
|
|
31
|
-
- **Reference Validation** – Optionally enforce that all parent/child
|
|
31
|
+
- **Reference Validation** – Optionally enforce that all parent/child references are resolved.
|
|
32
32
|
- **Depth Values** – Optionally include a depth value in each node.
|
|
33
33
|
|
|
34
34
|
## Installation
|
|
@@ -119,7 +119,7 @@ Builds a tree structure from an iterable list of items.
|
|
|
119
119
|
>
|
|
120
120
|
> Validation operates differently when in `parentId` mode and in `childIds` mode!
|
|
121
121
|
> * in `parentId` mode: validates that the parent IDs of root nodes was `null` or `undefined` and nothing else. If you expect these parent IDs to be other than `null` or `undefined`, you can safely turn off this validation and loop trough on the roots manually to check the original parentId values are the ones you expect.
|
|
122
|
-
> * in `childIds` mode: validates that every referenced child is resolved. Even if the child list contains `undefined
|
|
122
|
+
> * in `childIds` mode: validates that every referenced child is resolved. Even if the child ids list contains an `undefined` value, a node with an ID of `undefined` must exist in the input.
|
|
123
123
|
|
|
124
124
|
|
|
125
125
|
## Usage
|
|
@@ -315,7 +315,7 @@ console.log(roots);
|
|
|
315
315
|
|
|
316
316
|
If the above doesn't work for your case, define your tree node type from scratch.
|
|
317
317
|
|
|
318
|
-
We intentionally
|
|
318
|
+
We intentionally avoid providing a generic `TreeNode` type in the package, as maintaining a complex set of generic parameters is often more cumbersome and misleading than writing a custom recursive type yourself.
|
|
319
319
|
|
|
320
320
|
2. How can I present the `children` list in a specific order?
|
|
321
321
|
|
package/package.json
CHANGED