@cobol-ts/trees 0.0.14 → 0.0.17

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.
Files changed (2) hide show
  1. package/README.md +13 -7
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,15 +1,21 @@
1
1
  # @cobol-ts/trees
2
2
 
3
- ## Purpose
3
+ Transform or fold trees using supplied typeclass operations, with error-aware transformations.
4
4
 
5
- Format-independent functional traversals over tree structures. The COBOL [layout compiler](../../cursor-loader/layout/README.md) uses these operations to transform storage declarations and perform ordered geometry passes. This package knows nothing about COBOL syntax, byte buffers or projection lifetimes.
5
+ Traversals are generic; the layout compiler supplies COBOL-specific node semantics.
6
6
 
7
- ## Tree contracts
7
+ ## Traversals
8
8
 
9
- `Tree<Leaf, Child>` provides `isLeaf(node)` and `children(child)`. `MutableTree` extends that with `setChildren`. Callers supply these operations rather than inheriting from a fixed tree-node class.
9
+ - `transformTree` performs child-first transformations and returns `ErrorsOr`, allowing a branch to produce multiple nodes.
10
+ - `foldTreeLeft` is a left-to-right traversal with an optional exit callback after each branch's children.
11
+ - `foldTreeRight` walks in the complementary order needed for suffix calculations.
10
12
 
11
- ## Traversals
13
+ Implement `Tree<Leaf, Child>` to describe your own node structure; none of these functions assumes COBOL AST fields.
14
+
15
+ ## Source and tests
16
+
17
+ **Public entry points:** [tree.ts](./src/tree.ts).
12
18
 
13
- `transformTree(roots, tree, transform)` visits children before transforming their parent and returns `ErrorsOr`, allowing independent errors to accumulate through the [errors module](../errors/README.md). The transform callback can return multiple output nodes, so the operation also supports expansions and removals. `foldTreeLeft` walks in left-to-right depth-first order; its optional `exit` callback runs after the children of a branch. `foldTreeRight` walks in the complementary order used by suffix calculations.
19
+ **Tests:** [tree.spec.ts](src/tree.spec.ts)
14
20
 
15
- For geometry passes, traversal order is part of the algorithm: prefix placement and suffix sizing cannot be interchanged. See [`src/tree.ts`](src/tree.ts) and its tests for exact callback arguments and accumulation semantics.
21
+ **Related:** [@cobol-ts/layout](../../cursor-loader/layout/README.md) · [@cobol-ts/errors](../errors/README.md).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cobol-ts/trees",
3
3
  "description": "utilities walking, transforming and making trees",
4
- "version": "0.0.14",
4
+ "version": "0.0.17",
5
5
  "main": "dist/index",
6
6
  "types": "dist/index",
7
7
  "browserslist": {