@cobol-ts/trees 0.0.3 → 0.0.4
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/dist/index.js.map +1 -0
- package/dist/src/tree.d.ts +21 -0
- package/dist/src/tree.js +40 -0
- package/dist/src/tree.js.map +1 -0
- package/dist/src/tree.spec.d.ts +1 -0
- package/dist/src/tree.spec.js +257 -0
- package/dist/src/tree.spec.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ErrorsOr } from "@cobol-ts/errors";
|
|
2
|
+
export type TreeNode<Leaf, Child> = Leaf | Child;
|
|
3
|
+
export interface Tree<Leaf, Child> {
|
|
4
|
+
isLeaf(node: TreeNode<Leaf, Child>): node is Leaf;
|
|
5
|
+
children(node: Child): readonly TreeNode<Leaf, Child>[];
|
|
6
|
+
}
|
|
7
|
+
export interface MutableTree<Leaf, Child> extends Tree<Leaf, Child> {
|
|
8
|
+
setChildren(node: Child, children: readonly TreeNode<Leaf, Child>[]): void;
|
|
9
|
+
}
|
|
10
|
+
/** Transform children first; collect errors from independent subtrees. */
|
|
11
|
+
export declare function transformTree<InLeaf, InChild, OutLeaf, OutChild>(roots: readonly TreeNode<InLeaf, InChild>[], tree: Tree<InLeaf, InChild>, transform: (node: TreeNode<InLeaf, InChild>, children: readonly TreeNode<OutLeaf, OutChild>[]) => ErrorsOr<readonly TreeNode<OutLeaf, OutChild>[]>): ErrorsOr<TreeNode<OutLeaf, OutChild>[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Left-to-right depth-first fold.
|
|
14
|
+
*
|
|
15
|
+
* Optional exit runs AFTER visiting a branch's children. This is useful for
|
|
16
|
+
* context-dependent geometry: the parent can close its physical extent once
|
|
17
|
+
* all of its children have been measured. Existing callers are unchanged.
|
|
18
|
+
*/
|
|
19
|
+
export declare function foldTreeLeft<Leaf, Child, Acc>(roots: readonly TreeNode<Leaf, Child>[], tree: Tree<Leaf, Child>, initial: Acc, fold: (acc: Acc, node: TreeNode<Leaf, Child>) => Acc, exit?: (acc: Acc, node: Child) => Acc): Acc;
|
|
20
|
+
/** Right-to-left depth-first fold, children before their parent. */
|
|
21
|
+
export declare function foldTreeRight<Leaf, Child, Acc>(roots: readonly TreeNode<Leaf, Child>[], tree: Tree<Leaf, Child>, initial: Acc, fold: (acc: Acc, node: TreeNode<Leaf, Child>) => Acc): Acc;
|
package/dist/src/tree.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformTree = transformTree;
|
|
4
|
+
exports.foldTreeLeft = foldTreeLeft;
|
|
5
|
+
exports.foldTreeRight = foldTreeRight;
|
|
6
|
+
const errors_1 = require("@cobol-ts/errors");
|
|
7
|
+
/** Transform children first; collect errors from independent subtrees. */
|
|
8
|
+
function transformTree(roots, tree, transform) {
|
|
9
|
+
const many = (nodes) => (0, errors_1.mapErrorsOr)((0, errors_1.flattenArrayOfErrorsOr)(nodes.map(visit)), results => results.flatMap(result => result));
|
|
10
|
+
const visit = (node) => (0, errors_1.flatMapErrorsOr)(tree.isLeaf(node) ? (0, errors_1.value)([]) : many(tree.children(node)), children => transform(node, children));
|
|
11
|
+
return many(roots);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Left-to-right depth-first fold.
|
|
15
|
+
*
|
|
16
|
+
* Optional exit runs AFTER visiting a branch's children. This is useful for
|
|
17
|
+
* context-dependent geometry: the parent can close its physical extent once
|
|
18
|
+
* all of its children have been measured. Existing callers are unchanged.
|
|
19
|
+
*/
|
|
20
|
+
function foldTreeLeft(roots, tree, initial, fold, exit) {
|
|
21
|
+
const visit = (acc, node) => {
|
|
22
|
+
const next = fold(acc, node);
|
|
23
|
+
if (tree.isLeaf(node))
|
|
24
|
+
return next;
|
|
25
|
+
const afterChildren = tree.children(node).reduce(visit, next);
|
|
26
|
+
return exit ? exit(afterChildren, node) : afterChildren;
|
|
27
|
+
};
|
|
28
|
+
return roots.reduce(visit, initial);
|
|
29
|
+
}
|
|
30
|
+
/** Right-to-left depth-first fold, children before their parent. */
|
|
31
|
+
function foldTreeRight(roots, tree, initial, fold) {
|
|
32
|
+
const visit = (acc, node) => {
|
|
33
|
+
const next = tree.isLeaf(node)
|
|
34
|
+
? acc
|
|
35
|
+
: tree.children(node).reduceRight(visit, acc);
|
|
36
|
+
return fold(next, node);
|
|
37
|
+
};
|
|
38
|
+
return roots.reduceRight(visit, initial);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/tree.ts"],"names":[],"mappings":";;AAoBA,sCAwBC;AASD,oCAcC;AAGD,sCAaC;AAnFD,6CAM0B;AAa1B,0EAA0E;AAC1E,SAAgB,aAAa,CACzB,KAA2C,EAC3C,IAA2B,EAC3B,SAGqD;IAKrD,MAAM,IAAI,GAAG,CAAC,KAAuB,EAAsB,EAAE,CACzD,IAAA,oBAAW,EACP,IAAA,+BAAsB,EAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EACxC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAC/C,CAAC;IAEN,MAAM,KAAK,GAAG,CAAC,IAAW,EAA+B,EAAE,CACvD,IAAA,wBAAe,EACX,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EACrE,QAAQ,CAAC,E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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tree_1 = require("./tree");
|
|
4
|
+
const errors_1 = require("@cobol-ts/errors");
|
|
5
|
+
const sourceTree = {
|
|
6
|
+
isLeaf: (node) => node.kind === "leaf",
|
|
7
|
+
children: node => node.children
|
|
8
|
+
};
|
|
9
|
+
const mutableSourceTree = {
|
|
10
|
+
...sourceTree,
|
|
11
|
+
setChildren: (node, children) => {
|
|
12
|
+
node.children = [...children];
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const leaf = (name) => ({ kind: "leaf", name });
|
|
16
|
+
const branch = (name, ...children) => ({
|
|
17
|
+
kind: "branch",
|
|
18
|
+
name,
|
|
19
|
+
children
|
|
20
|
+
});
|
|
21
|
+
const targetLeaf = (text) => ({ kind: "value", text });
|
|
22
|
+
const targetBranch = (label, ...children) => ({
|
|
23
|
+
kind: "container",
|
|
24
|
+
label,
|
|
25
|
+
children
|
|
26
|
+
});
|
|
27
|
+
const sample = () => [
|
|
28
|
+
branch("root", leaf("A"), branch("nested", leaf("B"), leaf("C")), leaf("D"))
|
|
29
|
+
];
|
|
30
|
+
/** Supply both output node types explicitly to avoid `readonly unknown[]` inference. */
|
|
31
|
+
function transformSourceTree(roots, transform) {
|
|
32
|
+
return (0, tree_1.transformTree)(roots, sourceTree, transform);
|
|
33
|
+
}
|
|
34
|
+
const compileNode = (node, children) => (0, errors_1.value)(node.kind === "leaf"
|
|
35
|
+
? [targetLeaf(node.name.toLowerCase())]
|
|
36
|
+
: [targetBranch(node.name, ...children)]);
|
|
37
|
+
describe("@cobol-ts/tree", () => {
|
|
38
|
+
describe("transformTree", () => {
|
|
39
|
+
test("transforms a leaf into a different type", () => {
|
|
40
|
+
expect((0, errors_1.valueOrThrow)(transformSourceTree([leaf("A")], compileNode)))
|
|
41
|
+
.toEqual([targetLeaf("a")]);
|
|
42
|
+
});
|
|
43
|
+
test("preserves hierarchy while changing node types", () => {
|
|
44
|
+
expect((0, errors_1.valueOrThrow)(transformSourceTree(sample(), compileNode))).toEqual([
|
|
45
|
+
targetBranch("root", targetLeaf("a"), targetBranch("nested", targetLeaf("b"), targetLeaf("c")), targetLeaf("d"))
|
|
46
|
+
]);
|
|
47
|
+
});
|
|
48
|
+
test("transforms children before their parent", () => {
|
|
49
|
+
const visited = [];
|
|
50
|
+
(0, errors_1.valueOrThrow)(transformSourceTree(sample(), (node, children) => {
|
|
51
|
+
visited.push(node.name);
|
|
52
|
+
return compileNode(node, children);
|
|
53
|
+
}));
|
|
54
|
+
expect(visited).toEqual(["A", "B", "C", "nested", "D", "root"]);
|
|
55
|
+
});
|
|
56
|
+
test("preserves sibling order", () => {
|
|
57
|
+
const result = (0, errors_1.valueOrThrow)(transformSourceTree([branch("root", leaf("C"), leaf("A"), leaf("B"))], compileNode));
|
|
58
|
+
expect(result).toEqual([
|
|
59
|
+
targetBranch("root", targetLeaf("c"), targetLeaf("a"), targetLeaf("b"))
|
|
60
|
+
]);
|
|
61
|
+
});
|
|
62
|
+
test("handles an empty forest", () => {
|
|
63
|
+
const result = (0, errors_1.valueOrThrow)(transformSourceTree([], () => {
|
|
64
|
+
throw new Error("Transform must not be called");
|
|
65
|
+
}));
|
|
66
|
+
expect(result).toEqual([]);
|
|
67
|
+
});
|
|
68
|
+
test("does not mutate the source tree", () => {
|
|
69
|
+
const roots = sample();
|
|
70
|
+
const before = JSON.parse(JSON.stringify(roots));
|
|
71
|
+
(0, errors_1.valueOrThrow)(transformSourceTree(roots, compileNode));
|
|
72
|
+
expect(roots).toEqual(before);
|
|
73
|
+
});
|
|
74
|
+
test("can expand one leaf to several nodes", () => {
|
|
75
|
+
const result = (0, errors_1.valueOrThrow)(transformSourceTree([branch("root", leaf("A"), leaf("B"))], (node, children) => (0, errors_1.value)(node.kind === "leaf"
|
|
76
|
+
? [targetLeaf(node.name), targetLeaf("PADDING")]
|
|
77
|
+
: [targetBranch(node.name, ...children)])));
|
|
78
|
+
expect(result).toEqual([
|
|
79
|
+
targetBranch("root", targetLeaf("A"), targetLeaf("PADDING"), targetLeaf("B"), targetLeaf("PADDING"))
|
|
80
|
+
]);
|
|
81
|
+
});
|
|
82
|
+
test("can remove a node by returning no outputs", () => {
|
|
83
|
+
const result = (0, errors_1.valueOrThrow)(transformSourceTree([branch("root", leaf("A"), leaf("REMOVE"), leaf("B"))], (node, children) => (0, errors_1.value)(node.kind === "leaf"
|
|
84
|
+
? (node.name === "REMOVE" ? [] : [targetLeaf(node.name)])
|
|
85
|
+
: [targetBranch(node.name, ...children)])));
|
|
86
|
+
expect(result).toEqual([
|
|
87
|
+
targetBranch("root", targetLeaf("A"), targetLeaf("B"))
|
|
88
|
+
]);
|
|
89
|
+
});
|
|
90
|
+
test("can expand multiple roots", () => {
|
|
91
|
+
const result = (0, errors_1.valueOrThrow)(transformSourceTree([leaf("A"), leaf("B")], node => (0, errors_1.value)(node.kind === "leaf"
|
|
92
|
+
? [targetLeaf(node.name), targetLeaf(`${node.name}-extra`)]
|
|
93
|
+
: [])));
|
|
94
|
+
expect(result).toEqual([
|
|
95
|
+
targetLeaf("A"), targetLeaf("A-extra"),
|
|
96
|
+
targetLeaf("B"), targetLeaf("B-extra")
|
|
97
|
+
]);
|
|
98
|
+
});
|
|
99
|
+
test("can remove a complete subtree", () => {
|
|
100
|
+
const result = (0, errors_1.valueOrThrow)(transformSourceTree([branch("root", branch("REMOVE", leaf("A"), leaf("B")), leaf("C"))], (node, children) => (0, errors_1.value)(node.kind === "leaf"
|
|
101
|
+
? [targetLeaf(node.name)]
|
|
102
|
+
: node.name === "REMOVE" ? [] : [targetBranch(node.name, ...children)])));
|
|
103
|
+
expect(result).toEqual([targetBranch("root", targetLeaf("C"))]);
|
|
104
|
+
});
|
|
105
|
+
test("can expand a branch into multiple branches", () => {
|
|
106
|
+
const result = (0, errors_1.valueOrThrow)(transformSourceTree([branch("root", leaf("A"))], (node, children) => (0, errors_1.value)(node.kind === "leaf"
|
|
107
|
+
? [targetLeaf(node.name)]
|
|
108
|
+
: [
|
|
109
|
+
targetBranch(`${node.name}-first`, ...children),
|
|
110
|
+
targetBranch(`${node.name}-second`, ...children)
|
|
111
|
+
])));
|
|
112
|
+
expect(result).toEqual([
|
|
113
|
+
targetBranch("root-first", targetLeaf("A")),
|
|
114
|
+
targetBranch("root-second", targetLeaf("A"))
|
|
115
|
+
]);
|
|
116
|
+
});
|
|
117
|
+
describe("error aggregation", () => {
|
|
118
|
+
const compileWithErrors = (node, children) => node.name.startsWith("BAD")
|
|
119
|
+
? (0, errors_1.errors)(`Invalid ${node.name}`)
|
|
120
|
+
: compileNode(node, children);
|
|
121
|
+
test("propagates a single error", () => {
|
|
122
|
+
expect((0, errors_1.errorsOrThrow)(transformSourceTree([leaf("BAD-A")], compileWithErrors)))
|
|
123
|
+
.toEqual(["Invalid BAD-A"]);
|
|
124
|
+
});
|
|
125
|
+
test("collects errors from all siblings", () => {
|
|
126
|
+
const visited = [];
|
|
127
|
+
const result = transformSourceTree([branch("root", leaf("BAD-A"), leaf("GOOD"), leaf("BAD-B"))], (node, children) => {
|
|
128
|
+
visited.push(node.name);
|
|
129
|
+
return compileWithErrors(node, children);
|
|
130
|
+
});
|
|
131
|
+
expect((0, errors_1.errorsOrThrow)(result)).toEqual(["Invalid BAD-A", "Invalid BAD-B"]);
|
|
132
|
+
expect(visited).toEqual(["BAD-A", "GOOD", "BAD-B"]);
|
|
133
|
+
});
|
|
134
|
+
test("collects errors from independent subtrees", () => {
|
|
135
|
+
const visited = [];
|
|
136
|
+
const result = transformSourceTree([branch("first", leaf("BAD-A")), branch("second", leaf("BAD-B"))], (node, children) => {
|
|
137
|
+
visited.push(node.name);
|
|
138
|
+
return compileWithErrors(node, children);
|
|
139
|
+
});
|
|
140
|
+
expect((0, errors_1.errorsOrThrow)(result)).toEqual(["Invalid BAD-A", "Invalid BAD-B"]);
|
|
141
|
+
expect(visited).toEqual(["BAD-A", "BAD-B"]);
|
|
142
|
+
});
|
|
143
|
+
test("collects errors from separate roots in order", () => {
|
|
144
|
+
expect((0, errors_1.errorsOrThrow)(transformSourceTree([leaf("BAD-A"), leaf("BAD-B"), leaf("BAD-C")], compileWithErrors))).toEqual(["Invalid BAD-A", "Invalid BAD-B", "Invalid BAD-C"]);
|
|
145
|
+
});
|
|
146
|
+
test("collects multiple errors produced by each node", () => {
|
|
147
|
+
expect((0, errors_1.errorsOrThrow)(transformSourceTree([leaf("A"), leaf("B")], node => (0, errors_1.errors)(`${node.name}: missing PIC`, `${node.name}: unsupported USAGE`)))).toEqual([
|
|
148
|
+
"A: missing PIC", "A: unsupported USAGE",
|
|
149
|
+
"B: missing PIC", "B: unsupported USAGE"
|
|
150
|
+
]);
|
|
151
|
+
});
|
|
152
|
+
test("does not transform a parent with failed children", () => {
|
|
153
|
+
const visited = [];
|
|
154
|
+
const result = transformSourceTree([branch("root", leaf("GOOD"), leaf("BAD-A"))], (node, children) => {
|
|
155
|
+
visited.push(node.name);
|
|
156
|
+
return compileWithErrors(node, children);
|
|
157
|
+
});
|
|
158
|
+
expect((0, errors_1.errorsOrThrow)(result)).toEqual(["Invalid BAD-A"]);
|
|
159
|
+
expect(visited).toEqual(["GOOD", "BAD-A"]);
|
|
160
|
+
});
|
|
161
|
+
test("continues compiling unaffected branches after failure", () => {
|
|
162
|
+
const visited = [];
|
|
163
|
+
const result = transformSourceTree([branch("first", leaf("BAD-A")),
|
|
164
|
+
branch("second", leaf("GOOD")), leaf("BAD-B")], (node, children) => {
|
|
165
|
+
visited.push(node.name);
|
|
166
|
+
return compileWithErrors(node, children);
|
|
167
|
+
});
|
|
168
|
+
expect((0, errors_1.errorsOrThrow)(result)).toEqual(["Invalid BAD-A", "Invalid BAD-B"]);
|
|
169
|
+
expect(visited).toEqual(["BAD-A", "GOOD", "second", "BAD-B"]);
|
|
170
|
+
});
|
|
171
|
+
test("returns transformed values when there are no errors", () => {
|
|
172
|
+
expect((0, errors_1.valueOrThrow)(transformSourceTree([leaf("A"), leaf("B")], compileWithErrors))).toEqual([targetLeaf("a"), targetLeaf("b")]);
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
describe("foldTreeLeft", () => {
|
|
177
|
+
test("visits parents before children, left to right", () => {
|
|
178
|
+
const names = (0, tree_1.foldTreeLeft)(sample(), sourceTree, [], (acc, node) => [...acc, node.name]);
|
|
179
|
+
expect(names).toEqual(["root", "A", "nested", "B", "C", "D"]);
|
|
180
|
+
});
|
|
181
|
+
test("carries its accumulator across roots", () => {
|
|
182
|
+
expect((0, tree_1.foldTreeLeft)([branch("first", leaf("A")), leaf("B")], sourceTree, "", (acc, node) => acc + node.name)).toBe("firstAB");
|
|
183
|
+
});
|
|
184
|
+
test("returns the initial value for an empty forest", () => {
|
|
185
|
+
expect((0, tree_1.foldTreeLeft)([], sourceTree, 42, acc => acc + 1)).toBe(42);
|
|
186
|
+
});
|
|
187
|
+
test("visits a lone leaf", () => {
|
|
188
|
+
expect((0, tree_1.foldTreeLeft)([leaf("A")], sourceTree, [], (acc, node) => [...acc, node.name])).toEqual(["A"]);
|
|
189
|
+
});
|
|
190
|
+
test("can mutate visited nodes", () => {
|
|
191
|
+
const root = branch("ROOT", leaf("A"), branch("INNER", leaf("B")));
|
|
192
|
+
(0, tree_1.foldTreeLeft)([root], mutableSourceTree, undefined, (acc, node) => {
|
|
193
|
+
node.name = node.name.toLowerCase();
|
|
194
|
+
return acc;
|
|
195
|
+
});
|
|
196
|
+
expect(root).toEqual(branch("root", leaf("a"), branch("inner", leaf("b"))));
|
|
197
|
+
});
|
|
198
|
+
describe("optional exit callback", () => {
|
|
199
|
+
test("runs after each branch's descendants", () => {
|
|
200
|
+
const events = (0, tree_1.foldTreeLeft)([branch("ROOT", leaf("A"), branch("INNER", leaf("B")))], sourceTree, [], (acc, node) => [...acc, `enter ${node.name}`], (acc, node) => [...acc, `exit ${node.name}`]);
|
|
201
|
+
expect(events).toEqual([
|
|
202
|
+
"enter ROOT", "enter A", "enter INNER", "enter B",
|
|
203
|
+
"exit INNER", "exit ROOT"
|
|
204
|
+
]);
|
|
205
|
+
});
|
|
206
|
+
test("is called for branches, not leaves", () => {
|
|
207
|
+
const exited = [];
|
|
208
|
+
(0, tree_1.foldTreeLeft)([leaf("A"), branch("ROOT", leaf("B"))], sourceTree, undefined, acc => acc, (acc, node) => {
|
|
209
|
+
exited.push(node.name);
|
|
210
|
+
return acc;
|
|
211
|
+
});
|
|
212
|
+
expect(exited).toEqual(["ROOT"]);
|
|
213
|
+
});
|
|
214
|
+
test("receives the accumulator returned by the child traversal", () => {
|
|
215
|
+
const result = (0, tree_1.foldTreeLeft)([branch("ROOT", leaf("A"), leaf("B"))], sourceTree, "", (acc, node) => acc + node.name, (acc, node) => `${acc}[/${node.name}]`);
|
|
216
|
+
expect(result).toBe("ROOTAB[/ROOT]");
|
|
217
|
+
});
|
|
218
|
+
test("preserves the four-argument call signature", () => {
|
|
219
|
+
expect((0, tree_1.foldTreeLeft)([branch("ROOT", leaf("A"), leaf("B"))], sourceTree, "", (acc, node) => acc + node.name)).toBe("ROOTAB");
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
describe("foldTreeRight", () => {
|
|
224
|
+
test("visits children before parents, right to left", () => {
|
|
225
|
+
expect((0, tree_1.foldTreeRight)(sample(), sourceTree, [], (acc, node) => [...acc, node.name])).toEqual(["D", "C", "B", "nested", "A", "root"]);
|
|
226
|
+
});
|
|
227
|
+
test("carries its accumulator across roots", () => {
|
|
228
|
+
expect((0, tree_1.foldTreeRight)([branch("first", leaf("A")), leaf("B")], sourceTree, "", (acc, node) => acc + node.name)).toBe("BAfirst");
|
|
229
|
+
});
|
|
230
|
+
test("returns the initial value for an empty forest", () => {
|
|
231
|
+
expect((0, tree_1.foldTreeRight)([], sourceTree, 42, acc => acc + 1)).toBe(42);
|
|
232
|
+
});
|
|
233
|
+
test("visits a lone leaf", () => {
|
|
234
|
+
expect((0, tree_1.foldTreeRight)([leaf("A")], sourceTree, [], (acc, node) => [...acc, node.name])).toEqual(["A"]);
|
|
235
|
+
});
|
|
236
|
+
test("can mutate visited nodes", () => {
|
|
237
|
+
const root = branch("ROOT", leaf("A"), branch("INNER", leaf("B")));
|
|
238
|
+
(0, tree_1.foldTreeRight)([root], mutableSourceTree, undefined, (acc, node) => {
|
|
239
|
+
node.name = node.name.toLowerCase();
|
|
240
|
+
return acc;
|
|
241
|
+
});
|
|
242
|
+
expect(root).toEqual(branch("root", leaf("a"), branch("inner", leaf("b"))));
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
describe("MutableTree", () => {
|
|
246
|
+
test("replaces a branch's children", () => {
|
|
247
|
+
const root = branch("root", leaf("A"), leaf("B"));
|
|
248
|
+
mutableSourceTree.setChildren(root, [leaf("C"), branch("nested", leaf("D"))]);
|
|
249
|
+
expect(root).toEqual(branch("root", leaf("C"), branch("nested", leaf("D"))));
|
|
250
|
+
});
|
|
251
|
+
test("also supports the read-only children interface", () => {
|
|
252
|
+
const root = branch("root", leaf("A"));
|
|
253
|
+
expect(mutableSourceTree.children(root)).toEqual([leaf("A")]);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
//# sourceMappingURL=tree.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.spec.js","sourceRoot":"","sources":["../../src/tree.spec.ts"],"names":[],"mappings":";;AAAA,iCAMgB;AAEhB,6CAM0B;AAU1B,MAAM,UAAU,GAAmC;IAC/C,MAAM,EAAE,CAAC,IAAI,EAAsB,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM;IAC1D,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ;CAClC,CAAC;AAEF,MAAM,iBAAiB,GAA0C;IAC7D,GAAG,UAAU;IACb,WAAW,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE;Q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ClE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
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.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"types": "dist/index",
|
|
7
7
|
"browserslist": {
|
|
@@ -45,7 +45,8 @@
|
|
|
45
45
|
"dist/index.js",
|
|
46
46
|
"dist/index.d.ts",
|
|
47
47
|
"dist/src/",
|
|
48
|
-
"build/"
|
|
48
|
+
"build/",
|
|
49
|
+
"dist/**/*"
|
|
49
50
|
],
|
|
50
51
|
"keywords": [
|
|
51
52
|
"indexing"
|