pacc 9.2.4 → 9.2.5
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/benchmark/first.mjs +48 -0
- package/package.json +4 -1
- package/src/parser.mjs +2 -2
- package/types/parser.d.mts +2 -2
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { run, bench, boxplot, summary } from "mitata";
|
|
2
|
+
import { tokens } from "../src/tokens.mjs";
|
|
3
|
+
import { parse, parseOnly } from "../src/parser.mjs";
|
|
4
|
+
|
|
5
|
+
const root = new Map([
|
|
6
|
+
["a", { n: 1, l: [1, 2] }],
|
|
7
|
+
["b", { n: 3, x: 7, l: [3, 4] }],
|
|
8
|
+
[
|
|
9
|
+
"c",
|
|
10
|
+
{
|
|
11
|
+
d: {
|
|
12
|
+
e: { f: { g: { h: { i: { j: { k: { l: { m: { n: "xyz" } } } } } } } } }
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
const root2 = {
|
|
19
|
+
a: {
|
|
20
|
+
b: {
|
|
21
|
+
c: {
|
|
22
|
+
d: {
|
|
23
|
+
e: {
|
|
24
|
+
f: { g: { h: { i: { j: { k: { l: { m: { n: "xyz" } } } } } } } }
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
bench('"[n<5].l"', () => parse("[n<5].l", { root }));
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const expression = "a.b.c.d.e.f.g.h.i.j.k.l.m.n";
|
|
36
|
+
|
|
37
|
+
bench('"a.b.c.d.e.f.g.h.i.j.k.l.m.n"', () =>
|
|
38
|
+
parse(expression, { root: root2 })
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
bench('parseOnly "a.b.c.d.e.f.g.h.i.j.k.l.m.n"', () =>
|
|
42
|
+
parseOnly(expression, { })
|
|
43
|
+
);
|
|
44
|
+
bench('tokens "a.b.c.d.e.f.g.h.i.j.k.l.m.n"', () =>
|
|
45
|
+
Array.from(tokens(expression, { }))
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
await run();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pacc",
|
|
3
|
-
"version": "9.2.
|
|
3
|
+
"version": "9.2.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"license": "0BSD",
|
|
31
31
|
"scripts": {
|
|
32
|
+
"benchmark": "node benchmark/*.mjs",
|
|
32
33
|
"prepare": "node --run prepare:typescript",
|
|
33
34
|
"prepare:typescript": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types --resolveJsonModule --target esnext -m esnext --module nodenext --moduleResolution nodenext --rootDir src ./src**/*.mjs",
|
|
34
35
|
"test": "node --run test:browser-ava && node --run test:ava",
|
|
@@ -41,10 +42,12 @@
|
|
|
41
42
|
"lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
45
|
+
"@mitata/counters": "^0.0.8",
|
|
44
46
|
"ava": "^6.4.1",
|
|
45
47
|
"browser-ava": "^2.3.53",
|
|
46
48
|
"c8": "^10.1.3",
|
|
47
49
|
"documentation": "^14.0.3",
|
|
50
|
+
"mitata": "^1.0.34",
|
|
48
51
|
"semantic-release": "^25.0.3",
|
|
49
52
|
"typescript": "^5.9.3"
|
|
50
53
|
},
|
package/src/parser.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { tokens, EOF } from "./tokens.mjs";
|
|
2
2
|
|
|
3
|
-
export function parseOnly(input, context
|
|
3
|
+
export function parseOnly(input, context) {
|
|
4
4
|
input = tokens(input, context);
|
|
5
5
|
|
|
6
6
|
let token, value;
|
|
@@ -54,7 +54,7 @@ export function parseOnly(input, context = {}) {
|
|
|
54
54
|
return parser.expression(0);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
export function parse(input, context) {
|
|
57
|
+
export function parse(input, context={}) {
|
|
58
58
|
const result = parseOnly(input, context);
|
|
59
59
|
return result.eval ? result.eval(result, context.root, context) : result;
|
|
60
60
|
}
|
package/types/parser.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export function parseOnly(input: any, context
|
|
2
|
-
export function parse(input: any, context
|
|
1
|
+
export function parseOnly(input: any, context: any): any;
|
|
2
|
+
export function parse(input: any, context?: {}): any;
|