@bablr/agast-helpers 0.7.1 → 0.8.0
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/lib/builders.js +70 -27
- package/lib/children.js +120 -0
- package/lib/object.js +86 -0
- package/lib/path-facade.js +39 -0
- package/lib/path.js +386 -448
- package/lib/print.js +51 -87
- package/lib/shorthand.js +26 -1
- package/lib/stream.js +33 -13
- package/lib/symbols.js +3 -1
- package/lib/template.js +23 -36
- package/lib/tree.js +368 -122
- package/package.json +8 -5
- package/lib/sumtree.js +0 -62
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bablr/agast-helpers",
|
|
3
3
|
"description": "Helper functions for working with agAST trees",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"author": "Conrad Buck<conartist6@gmail.com>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
"exports": {
|
|
11
11
|
"./btree": "./lib/btree.js",
|
|
12
12
|
"./builders": "./lib/builders.js",
|
|
13
|
+
"./children": "./lib/children.js",
|
|
14
|
+
"./object": "./lib/object.js",
|
|
15
|
+
"./path-facade": "./lib/path-facade.js",
|
|
13
16
|
"./path": "./lib/path.js",
|
|
14
17
|
"./print": "./lib/print.js",
|
|
15
18
|
"./shorthand": "./lib/shorthand.js",
|
|
16
19
|
"./stream": "./lib/stream.js",
|
|
17
|
-
"./sumtree": "./lib/sumtree.js",
|
|
18
20
|
"./symbols": "./lib/symbols.js",
|
|
19
21
|
"./template": "./lib/template.js",
|
|
20
22
|
"./tree": "./lib/tree.js"
|
|
@@ -24,17 +26,18 @@
|
|
|
24
26
|
"test": "mocha test/*.test.js"
|
|
25
27
|
},
|
|
26
28
|
"dependencies": {
|
|
27
|
-
"@bablr/btree": "0.
|
|
29
|
+
"@bablr/btree": "0.4.0",
|
|
28
30
|
"@bablr/coroutine": "0.1.0",
|
|
29
|
-
"@bablr/weak-stack": "1.0.
|
|
31
|
+
"@bablr/weak-stack": "1.0.1",
|
|
30
32
|
"@iter-tools/imm-stack": "1.1.0"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
|
-
"@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#
|
|
35
|
+
"@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#c97bfa4b3663f8378e9b3e42bb5a41e685406cf9",
|
|
34
36
|
"enhanced-resolve": "^5.12.0",
|
|
35
37
|
"eslint": "^8.32.0",
|
|
36
38
|
"eslint-import-resolver-enhanced-resolve": "^1.0.5",
|
|
37
39
|
"eslint-plugin-import": "^2.27.5",
|
|
40
|
+
"expect": "^29.7.0",
|
|
38
41
|
"mocha": "^10.8.2",
|
|
39
42
|
"prettier": "^2.6.2"
|
|
40
43
|
},
|
package/lib/sumtree.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { buildModule, defaultNodeSize } from '@bablr/btree/enhanceable';
|
|
2
|
-
import { LiteralTag, ReferenceTag } from './symbols.js';
|
|
3
|
-
|
|
4
|
-
const { isArray } = Array;
|
|
5
|
-
const { freeze } = Object;
|
|
6
|
-
|
|
7
|
-
export { defaultNodeSize };
|
|
8
|
-
|
|
9
|
-
export const {
|
|
10
|
-
treeFrom,
|
|
11
|
-
treeFromValues,
|
|
12
|
-
findBalancePoint,
|
|
13
|
-
splitValues,
|
|
14
|
-
collapses,
|
|
15
|
-
nodeCollapses,
|
|
16
|
-
nodeCanDonate,
|
|
17
|
-
pop,
|
|
18
|
-
push,
|
|
19
|
-
addAt,
|
|
20
|
-
isValidNode,
|
|
21
|
-
assertValidNode,
|
|
22
|
-
getValues,
|
|
23
|
-
getSums,
|
|
24
|
-
setValues,
|
|
25
|
-
isLeafNode,
|
|
26
|
-
traverse,
|
|
27
|
-
getSize,
|
|
28
|
-
findPath,
|
|
29
|
-
getAt,
|
|
30
|
-
replaceAt,
|
|
31
|
-
} = buildModule(
|
|
32
|
-
defaultNodeSize,
|
|
33
|
-
(acc, val) => {
|
|
34
|
-
const { references } = acc;
|
|
35
|
-
if (isArray(val)) {
|
|
36
|
-
acc.lineBreaks += val[2].lineBreaks;
|
|
37
|
-
for (const { 0: key, 1: value } of Object.entries(val[2].references)) {
|
|
38
|
-
references[key] = (references[key] ?? 0) + value;
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
if (val.type === LiteralTag) {
|
|
42
|
-
let text = val.value;
|
|
43
|
-
let idx = 0;
|
|
44
|
-
while ((idx = text.indexOf('\n', idx + 1)) >= 0) {
|
|
45
|
-
acc.lineBreaks++;
|
|
46
|
-
}
|
|
47
|
-
} else if (val.type === ReferenceTag) {
|
|
48
|
-
const { name } = val.value;
|
|
49
|
-
references[name] = (references[name] ?? 0) + 1;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return acc;
|
|
53
|
-
},
|
|
54
|
-
() => ({
|
|
55
|
-
lineBreaks: 0,
|
|
56
|
-
references: {},
|
|
57
|
-
}),
|
|
58
|
-
(stats) => {
|
|
59
|
-
freeze(stats);
|
|
60
|
-
freeze(stats.references);
|
|
61
|
-
},
|
|
62
|
-
);
|