pacc 8.6.3 → 8.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/README.md +148 -143
- package/package.json +3 -3
- package/src/expand.mjs +14 -5
- package/src/expression.mjs +4 -0
- package/types/expand.d.mts +14 -3
- package/types/expression.d.mts +4 -0
package/README.md
CHANGED
|
@@ -30,144 +30,141 @@ const result = expand("${a + 1}",{ root: { a: 2 }});
|
|
|
30
30
|
|
|
31
31
|
### Table of Contents
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
- [Parameters](#parameters-19)
|
|
169
|
-
- [install](#install)
|
|
170
|
-
- [license](#license)
|
|
33
|
+
* [AST](#ast)
|
|
34
|
+
* [Properties](#properties)
|
|
35
|
+
* [binopError](#binoperror)
|
|
36
|
+
* [Parameters](#parameters)
|
|
37
|
+
* [prepareAttributesDefinitions](#prepareattributesdefinitions)
|
|
38
|
+
* [Parameters](#parameters-1)
|
|
39
|
+
* [mergeAttributeDefinitions](#mergeattributedefinitions)
|
|
40
|
+
* [Parameters](#parameters-2)
|
|
41
|
+
* [attributeIterator](#attributeiterator)
|
|
42
|
+
* [Parameters](#parameters-3)
|
|
43
|
+
* [parseBytes](#parsebytes)
|
|
44
|
+
* [Parameters](#parameters-4)
|
|
45
|
+
* [AttributeDefinition](#attributedefinition)
|
|
46
|
+
* [Properties](#properties-1)
|
|
47
|
+
* [default\_attribute](#default_attribute)
|
|
48
|
+
* [default\_attribute](#default_attribute-1)
|
|
49
|
+
* [default\_attribute](#default_attribute-2)
|
|
50
|
+
* [default\_attribute\_writable](#default_attribute_writable)
|
|
51
|
+
* [default\_attribute\_writable](#default_attribute_writable-1)
|
|
52
|
+
* [default\_attribute\_writable](#default_attribute_writable-2)
|
|
53
|
+
* [default\_attribute\_writable](#default_attribute_writable-3)
|
|
54
|
+
* [string\_collection\_attribute](#string_collection_attribute)
|
|
55
|
+
* [string\_collection\_attribute\_writable](#string_collection_attribute_writable)
|
|
56
|
+
* [string\_set\_attribute](#string_set_attribute)
|
|
57
|
+
* [string\_set\_attribute\_writable](#string_set_attribute_writable)
|
|
58
|
+
* [name\_attribute](#name_attribute)
|
|
59
|
+
* [name\_attribute\_writable](#name_attribute_writable)
|
|
60
|
+
* [email\_attribute](#email_attribute)
|
|
61
|
+
* [version\_attribute](#version_attribute)
|
|
62
|
+
* [version\_attribute\_writable](#version_attribute_writable)
|
|
63
|
+
* [description\_attribute](#description_attribute)
|
|
64
|
+
* [boolean\_attribute](#boolean_attribute)
|
|
65
|
+
* [boolean\_attribute](#boolean_attribute-1)
|
|
66
|
+
* [boolean\_attribute\_writable](#boolean_attribute_writable)
|
|
67
|
+
* [boolean\_attribute\_writable\_true](#boolean_attribute_writable_true)
|
|
68
|
+
* [boolean\_attribute\_writable\_true](#boolean_attribute_writable_true-1)
|
|
69
|
+
* [boolean\_attribute\_writable\_false](#boolean_attribute_writable_false)
|
|
70
|
+
* [boolean\_attribute\_false](#boolean_attribute_false)
|
|
71
|
+
* [yesno\_attribute](#yesno_attribute)
|
|
72
|
+
* [uuid\_attribute](#uuid_attribute)
|
|
73
|
+
* [secret\_attribute](#secret_attribute)
|
|
74
|
+
* [secret\_attribute](#secret_attribute-1)
|
|
75
|
+
* [secret\_attribute](#secret_attribute-2)
|
|
76
|
+
* [secret\_attribute](#secret_attribute-3)
|
|
77
|
+
* [secret\_attribute](#secret_attribute-4)
|
|
78
|
+
* [secret\_attribute\_writable](#secret_attribute_writable)
|
|
79
|
+
* [private\_key\_attribute](#private_key_attribute)
|
|
80
|
+
* [public\_key\_attribute](#public_key_attribute)
|
|
81
|
+
* [number\_attribute](#number_attribute)
|
|
82
|
+
* [number\_attribute\_writable](#number_attribute_writable)
|
|
83
|
+
* [integer\_attribute](#integer_attribute)
|
|
84
|
+
* [integer\_attribute](#integer_attribute-1)
|
|
85
|
+
* [integer\_attribute](#integer_attribute-2)
|
|
86
|
+
* [integer\_attribute\_writable](#integer_attribute_writable)
|
|
87
|
+
* [integer\_attribute\_writable](#integer_attribute_writable-1)
|
|
88
|
+
* [object\_attribute](#object_attribute)
|
|
89
|
+
* [url\_attribute](#url_attribute)
|
|
90
|
+
* [url\_attribute\_writable](#url_attribute_writable)
|
|
91
|
+
* [hostname\_attribute](#hostname_attribute)
|
|
92
|
+
* [port\_attribute](#port_attribute)
|
|
93
|
+
* [id\_attribute](#id_attribute)
|
|
94
|
+
* [title\_attribute\_writable](#title_attribute_writable)
|
|
95
|
+
* [priority\_attribute](#priority_attribute)
|
|
96
|
+
* [duration\_attribute](#duration_attribute)
|
|
97
|
+
* [duration\_attribute\_writable](#duration_attribute_writable)
|
|
98
|
+
* [duration\_ms\_attribute](#duration_ms_attribute)
|
|
99
|
+
* [timeout\_attribute](#timeout_attribute)
|
|
100
|
+
* [language\_attribute](#language_attribute)
|
|
101
|
+
* [environmentValues](#environmentvalues)
|
|
102
|
+
* [Parameters](#parameters-5)
|
|
103
|
+
* [expandContextDefault](#expandcontextdefault)
|
|
104
|
+
* [expandContextDoubbleCurly](#expandcontextdoubblecurly)
|
|
105
|
+
* [expand](#expand)
|
|
106
|
+
* [Parameters](#parameters-6)
|
|
107
|
+
* [promises](#promises)
|
|
108
|
+
* [filter](#filter)
|
|
109
|
+
* [Parameters](#parameters-7)
|
|
110
|
+
* [setAttributes](#setattributes)
|
|
111
|
+
* [Parameters](#parameters-8)
|
|
112
|
+
* [getAttributes](#getattributes)
|
|
113
|
+
* [Parameters](#parameters-9)
|
|
114
|
+
* [getAttributesJSON](#getattributesjson)
|
|
115
|
+
* [Parameters](#parameters-10)
|
|
116
|
+
* [tokens](#tokens)
|
|
117
|
+
* [tokens](#tokens-1)
|
|
118
|
+
* [Parameters](#parameters-11)
|
|
119
|
+
* [setAttribute](#setattribute)
|
|
120
|
+
* [Parameters](#parameters-12)
|
|
121
|
+
* [getAttribute](#getattribute)
|
|
122
|
+
* [Parameters](#parameters-13)
|
|
123
|
+
* [getAttributeAndOperator](#getattributeandoperator)
|
|
124
|
+
* [Parameters](#parameters-14)
|
|
125
|
+
* [parseDuration](#parseduration)
|
|
126
|
+
* [Parameters](#parameters-15)
|
|
127
|
+
* [formatDuration](#formatduration)
|
|
128
|
+
* [Parameters](#parameters-16)
|
|
129
|
+
* [formatDurationISO](#formatdurationiso)
|
|
130
|
+
* [Parameters](#parameters-17)
|
|
131
|
+
* [lookup](#lookup)
|
|
132
|
+
* [Token](#token)
|
|
133
|
+
* [Properties](#properties-2)
|
|
134
|
+
* [createToken](#createtoken)
|
|
135
|
+
* [Parameters](#parameters-18)
|
|
136
|
+
* [PLUS](#plus)
|
|
137
|
+
* [MINUS](#minus)
|
|
138
|
+
* [STAR](#star)
|
|
139
|
+
* [DIVIDE](#divide)
|
|
140
|
+
* [NOT](#not)
|
|
141
|
+
* [NOT\_EQUAL](#not_equal)
|
|
142
|
+
* [EQUAL](#equal)
|
|
143
|
+
* [GREATER](#greater)
|
|
144
|
+
* [GREATER\_EQUAL](#greater_equal)
|
|
145
|
+
* [LESS](#less)
|
|
146
|
+
* [LESS\_EQUAL](#less_equal)
|
|
147
|
+
* [OPEN\_ROUND](#open_round)
|
|
148
|
+
* [CLOSE\_ROUND](#close_round)
|
|
149
|
+
* [OPEN\_BRACKET](#open_bracket)
|
|
150
|
+
* [CLOSE\_BRACKET](#close_bracket)
|
|
151
|
+
* [OPEN\_CURLY](#open_curly)
|
|
152
|
+
* [CLOSE\_CURLY](#close_curly)
|
|
153
|
+
* [QUESTION](#question)
|
|
154
|
+
* [COLON](#colon)
|
|
155
|
+
* [SEMICOLON](#semicolon)
|
|
156
|
+
* [COMMA](#comma)
|
|
157
|
+
* [DOT](#dot)
|
|
158
|
+
* [AMPERSAND](#ampersand)
|
|
159
|
+
* [DOUBLE\_AMPERSAND](#double_ampersand)
|
|
160
|
+
* [BAR](#bar)
|
|
161
|
+
* [DOUBLE\_BAR](#double_bar)
|
|
162
|
+
* [IDENTIFIER](#identifier)
|
|
163
|
+
* [EOF](#eof)
|
|
164
|
+
* [Type](#type)
|
|
165
|
+
* [Properties](#properties-3)
|
|
166
|
+
* [raiseOnUnknownType](#raiseonunknowntype)
|
|
167
|
+
* [Parameters](#parameters-19)
|
|
171
168
|
|
|
172
169
|
## AST
|
|
173
170
|
|
|
@@ -497,6 +494,14 @@ Extract values from environment.
|
|
|
497
494
|
|
|
498
495
|
Returns **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))** undefined if no suitable environment variables have been found
|
|
499
496
|
|
|
497
|
+
## expandContextDefault
|
|
498
|
+
|
|
499
|
+
Default expand context
|
|
500
|
+
|
|
501
|
+
## expandContextDoubbleCurly
|
|
502
|
+
|
|
503
|
+
Expand context with doubble curly separaion '{{' '}}'
|
|
504
|
+
|
|
500
505
|
## expand
|
|
501
506
|
|
|
502
507
|
Expand expressions inside of object graphs.
|
|
@@ -504,14 +509,14 @@ Expand expressions inside of object graphs.
|
|
|
504
509
|
### Parameters
|
|
505
510
|
|
|
506
511
|
* `object` **any** 
|
|
507
|
-
* `context` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
|
|
512
|
+
* `context` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
|
|
508
513
|
|
|
509
|
-
* `context.root` **any
|
|
514
|
+
* `context.root` **any?** actual replacement values
|
|
510
515
|
* `context.stopClass` **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** 
|
|
511
|
-
* `context.leadIn` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
|
|
512
|
-
* `context.leadOut` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
|
|
516
|
+
* `context.leadIn` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** starting separator
|
|
517
|
+
* `context.leadOut` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** ending separator
|
|
513
518
|
|
|
514
|
-
Returns **any** 
|
|
519
|
+
Returns **(any | [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<any>)** 
|
|
515
520
|
|
|
516
521
|
## promises
|
|
517
522
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pacc",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.8.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
7
7
|
},
|
|
8
|
-
"packageManager": "npm@11.
|
|
8
|
+
"packageManager": "npm@11.9.0+sha512.04166853ddba142ca98f86fb57b1258a7c6c59ccb82acb3cf141b77a315898acaaed47395e74f7e0c7b69c486008e68be6a6381ef1aee5a23dd82e0e61decd68",
|
|
9
9
|
"types": "./types/module.d.mts",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"ava": "^6.4.1",
|
|
44
|
-
"browser-ava": "^2.3.
|
|
44
|
+
"browser-ava": "^2.3.53",
|
|
45
45
|
"c8": "^10.1.3",
|
|
46
46
|
"documentation": "^14.0.3",
|
|
47
47
|
"semantic-release": "^25.0.3",
|
package/src/expand.mjs
CHANGED
|
@@ -5,26 +5,35 @@ const maxNestingLevel = 8;
|
|
|
5
5
|
/**
|
|
6
6
|
* Default expand context
|
|
7
7
|
*/
|
|
8
|
-
const
|
|
8
|
+
export const expandContextDefault = {
|
|
9
9
|
root: {},
|
|
10
10
|
leadIn: "${",
|
|
11
11
|
leadOut: "}"
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Expand context with doubble curly separaion '{{' '}}'
|
|
16
|
+
*/
|
|
17
|
+
export const expandContextDoubbleCurly = {
|
|
18
|
+
...expandContextDefault,
|
|
19
|
+
leadIn: "{{",
|
|
20
|
+
leadOut: "}}"
|
|
21
|
+
};
|
|
22
|
+
|
|
14
23
|
/**
|
|
15
24
|
* Expand expressions inside of object graphs.
|
|
16
25
|
* @param {any} object
|
|
17
26
|
* @param {Object} context
|
|
18
|
-
* @param {any} [context.root]
|
|
27
|
+
* @param {any} [context.root] actual replacement values
|
|
19
28
|
* @param {function} [context.stopClass]
|
|
20
|
-
* @param {string} [context.leadIn]
|
|
21
|
-
* @param {string} [context.leadOut]
|
|
29
|
+
* @param {string} [context.leadIn] starting separator
|
|
30
|
+
* @param {string} [context.leadOut] ending separator
|
|
22
31
|
* @returns {any|Promise<any>}
|
|
23
32
|
*/
|
|
24
33
|
export function expand(object, context) {
|
|
25
34
|
const /** @type {Array<Promise<any>>} */ promises = [];
|
|
26
35
|
|
|
27
|
-
context = Object.assign({},
|
|
36
|
+
context = Object.assign({}, expandContextDefault, context);
|
|
28
37
|
const leadIn = context.leadIn;
|
|
29
38
|
const leadOut = context.leadOut;
|
|
30
39
|
|
package/src/expression.mjs
CHANGED
|
@@ -167,6 +167,10 @@ export const globals = {
|
|
|
167
167
|
abs: Math.abs,
|
|
168
168
|
min: Math.min,
|
|
169
169
|
max: Math.max,
|
|
170
|
+
encodeURI: encodeURI,
|
|
171
|
+
decodeURI: decodeURI,
|
|
172
|
+
encodeURIComponent: encodeURIComponent,
|
|
173
|
+
decodeURIComponent: decodeURIComponent,
|
|
170
174
|
uppercase: a => a.toUpperCase(),
|
|
171
175
|
lowercase: a => a.toLowerCase(),
|
|
172
176
|
substring: (s, a, b) => s.substring(a, b),
|
package/types/expand.d.mts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Expand expressions inside of object graphs.
|
|
3
3
|
* @param {any} object
|
|
4
4
|
* @param {Object} context
|
|
5
|
-
* @param {any} [context.root]
|
|
5
|
+
* @param {any} [context.root] actual replacement values
|
|
6
6
|
* @param {function} [context.stopClass]
|
|
7
|
-
* @param {string} [context.leadIn]
|
|
8
|
-
* @param {string} [context.leadOut]
|
|
7
|
+
* @param {string} [context.leadIn] starting separator
|
|
8
|
+
* @param {string} [context.leadOut] ending separator
|
|
9
9
|
* @returns {any|Promise<any>}
|
|
10
10
|
*/
|
|
11
11
|
export function expand(object: any, context: {
|
|
@@ -14,3 +14,14 @@ export function expand(object: any, context: {
|
|
|
14
14
|
leadIn?: string;
|
|
15
15
|
leadOut?: string;
|
|
16
16
|
}): any | Promise<any>;
|
|
17
|
+
export namespace expandContextDefault {
|
|
18
|
+
let root: {};
|
|
19
|
+
let leadIn: string;
|
|
20
|
+
let leadOut: string;
|
|
21
|
+
}
|
|
22
|
+
export namespace expandContextDoubbleCurly {
|
|
23
|
+
let leadIn_1: string;
|
|
24
|
+
export { leadIn_1 as leadIn };
|
|
25
|
+
let leadOut_1: string;
|
|
26
|
+
export { leadOut_1 as leadOut };
|
|
27
|
+
}
|
package/types/expression.d.mts
CHANGED
|
@@ -8,6 +8,10 @@ export namespace globals {
|
|
|
8
8
|
export let abs: (x: number) => number;
|
|
9
9
|
export let min: (...values: number[]) => number;
|
|
10
10
|
export let max: (...values: number[]) => number;
|
|
11
|
+
export let encodeURI: typeof globalThis.encodeURI;
|
|
12
|
+
export let decodeURI: typeof globalThis.decodeURI;
|
|
13
|
+
export let encodeURIComponent: typeof globalThis.encodeURIComponent;
|
|
14
|
+
export let decodeURIComponent: typeof globalThis.decodeURIComponent;
|
|
11
15
|
export function uppercase(a: any): any;
|
|
12
16
|
export function lowercase(a: any): any;
|
|
13
17
|
export function substring(s: any, a: any, b: any): any;
|