pacc 4.23.1 → 4.24.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/package.json +1 -1
- package/src/expand.mjs +1 -3
- package/src/expression.mjs +7 -4
- package/src/settergetter.mjs +2 -2
- package/types/expression.d.mts +1 -1
package/package.json
CHANGED
package/src/expand.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { parse } from "./expression.mjs";
|
|
2
|
-
import { tokens } from "./tokens.mjs";
|
|
3
2
|
|
|
4
3
|
const maxNestingLevel = 5;
|
|
5
4
|
|
|
@@ -20,8 +19,7 @@ export function expand(object, context) {
|
|
|
20
19
|
const v = object.replace(
|
|
21
20
|
/\$\{([^\}]*)\}/g,
|
|
22
21
|
(match, expression, offset, string) => {
|
|
23
|
-
|
|
24
|
-
let value = parse(context);
|
|
22
|
+
let value = parse(expression,context);
|
|
25
23
|
|
|
26
24
|
if (typeof value === "string" || value instanceof String) {
|
|
27
25
|
value = _expand(value, path);
|
package/src/expression.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
tokens,
|
|
2
3
|
DOT,
|
|
3
4
|
OPEN_ROUND,
|
|
4
5
|
CLOSE_ROUND,
|
|
@@ -51,7 +52,9 @@ export function binop(op, left, right, fallback) {
|
|
|
51
52
|
return fallback(op, left, right);
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
export function parse(context) {
|
|
55
|
+
export function parse(input, context = {}) {
|
|
56
|
+
input = tokens(input);
|
|
57
|
+
|
|
55
58
|
let node, token, value;
|
|
56
59
|
|
|
57
60
|
function error(message) {
|
|
@@ -80,9 +83,9 @@ export function parse(context) {
|
|
|
80
83
|
}
|
|
81
84
|
break;
|
|
82
85
|
case "object":
|
|
83
|
-
const
|
|
86
|
+
const r = result;
|
|
84
87
|
function* filter() {
|
|
85
|
-
for (const x of
|
|
88
|
+
for (const x of r) {
|
|
86
89
|
if (p.eval(p, x)) {
|
|
87
90
|
yield x;
|
|
88
91
|
}
|
|
@@ -96,7 +99,7 @@ export function parse(context) {
|
|
|
96
99
|
};
|
|
97
100
|
|
|
98
101
|
const advance = () => {
|
|
99
|
-
const next =
|
|
102
|
+
const next = input.next();
|
|
100
103
|
if (next.done) {
|
|
101
104
|
token = EOF;
|
|
102
105
|
} else {
|
package/src/settergetter.mjs
CHANGED
|
@@ -28,7 +28,7 @@ import { prepareValue } from "./attributes.mjs";
|
|
|
28
28
|
* @param {Object} definition type def
|
|
29
29
|
*/
|
|
30
30
|
export function setAttribute(object, expression, value, definition) {
|
|
31
|
-
const { path } = parse(
|
|
31
|
+
const { path } = parse(expression, { exec: false });
|
|
32
32
|
|
|
33
33
|
let anchor, anchorKey;
|
|
34
34
|
|
|
@@ -61,7 +61,7 @@ export function setAttribute(object, expression, value, definition) {
|
|
|
61
61
|
* @returns {any} value associated with the given property name
|
|
62
62
|
*/
|
|
63
63
|
export function getAttribute(object, expression, definition) {
|
|
64
|
-
const { path } = parse(
|
|
64
|
+
const { path } = parse(expression, { exec: false });
|
|
65
65
|
|
|
66
66
|
for (const key of path) {
|
|
67
67
|
if (object !== undefined) {
|
package/types/expression.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export function binop(op: any, left: any, right: any, fallback: any): any;
|
|
2
|
-
export function parse(
|
|
2
|
+
export function parse(input: any, context?: {}): any;
|