@bablr/agast-helpers 0.7.1 → 0.9.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 +110 -49
- package/lib/object.js +86 -0
- package/lib/path-facade.js +44 -0
- package/lib/path.js +780 -556
- package/lib/print.js +75 -97
- package/lib/shorthand.js +26 -1
- package/lib/stream.js +55 -163
- package/lib/symbols.js +6 -2
- package/lib/tags.js +236 -0
- package/lib/template.js +28 -37
- package/lib/tree.js +391 -213
- package/package.json +11 -6
- 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.9.0",
|
|
5
5
|
"author": "Conrad Buck<conartist6@gmail.com>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -10,12 +10,14 @@
|
|
|
10
10
|
"exports": {
|
|
11
11
|
"./btree": "./lib/btree.js",
|
|
12
12
|
"./builders": "./lib/builders.js",
|
|
13
|
+
"./object": "./lib/object.js",
|
|
14
|
+
"./path-facade": "./lib/path-facade.js",
|
|
13
15
|
"./path": "./lib/path.js",
|
|
14
16
|
"./print": "./lib/print.js",
|
|
15
17
|
"./shorthand": "./lib/shorthand.js",
|
|
16
18
|
"./stream": "./lib/stream.js",
|
|
17
|
-
"./sumtree": "./lib/sumtree.js",
|
|
18
19
|
"./symbols": "./lib/symbols.js",
|
|
20
|
+
"./tags": "./lib/tags.js",
|
|
19
21
|
"./template": "./lib/template.js",
|
|
20
22
|
"./tree": "./lib/tree.js"
|
|
21
23
|
},
|
|
@@ -24,17 +26,20 @@
|
|
|
24
26
|
"test": "mocha test/*.test.js"
|
|
25
27
|
},
|
|
26
28
|
"dependencies": {
|
|
27
|
-
"@bablr/btree": "0.
|
|
29
|
+
"@bablr/btree": "0.4.1",
|
|
28
30
|
"@bablr/coroutine": "0.1.0",
|
|
29
|
-
"@bablr/
|
|
30
|
-
"@
|
|
31
|
+
"@bablr/stream-iterator": "1.0.0",
|
|
32
|
+
"@bablr/weak-stack": "1.0.1",
|
|
33
|
+
"@iter-tools/imm-stack": "1.2.0"
|
|
31
34
|
},
|
|
32
35
|
"devDependencies": {
|
|
33
|
-
"@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#
|
|
36
|
+
"@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#c97bfa4b3663f8378e9b3e42bb5a41e685406cf9",
|
|
37
|
+
"@qnighy/dedent": "0.1.1",
|
|
34
38
|
"enhanced-resolve": "^5.12.0",
|
|
35
39
|
"eslint": "^8.32.0",
|
|
36
40
|
"eslint-import-resolver-enhanced-resolve": "^1.0.5",
|
|
37
41
|
"eslint-plugin-import": "^2.27.5",
|
|
42
|
+
"expect": "^29.7.0",
|
|
38
43
|
"mocha": "^10.8.2",
|
|
39
44
|
"prettier": "^2.6.2"
|
|
40
45
|
},
|
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
|
-
);
|