pacc 5.2.0 → 6.0.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 +13 -1
- package/package.json +3 -3
- package/src/common-attributes.mjs +1 -1
- package/src/time.mjs +33 -0
- package/src/types.mjs +2 -2
- package/types/common-attributes.d.mts +5 -1
- package/types/time.d.mts +6 -0
- package/types/types.d.mts +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
[](https://github.com/prettier/prettier)
|
|
9
9
|
[](http://commitizen.github.io/cz-cli/)
|
|
10
10
|
[](https://snyk.io/test/github/arlac77/pacc)
|
|
11
|
-
[](https://coveralls.io/github/arlac77/pacc)
|
|
12
11
|
|
|
13
12
|
# pacc
|
|
14
13
|
|
|
@@ -135,6 +134,8 @@ const result = getAttribute({ a: [0,{ b: 4 }]}, "a[1].b");
|
|
|
135
134
|
* [DOUBLE\_BAR](#double_bar)
|
|
136
135
|
* [IDENTIFIER](#identifier)
|
|
137
136
|
* [EOF](#eof)
|
|
137
|
+
* [Type](#type)
|
|
138
|
+
* [Properties](#properties-2)
|
|
138
139
|
|
|
139
140
|
## prepareAttributesDefinitions
|
|
140
141
|
|
|
@@ -182,6 +183,7 @@ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Globa
|
|
|
182
183
|
* `mandatory` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
|
|
183
184
|
* `collection` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
|
|
184
185
|
* `private` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** should the value be shown
|
|
186
|
+
* `credential` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** any type of credential
|
|
185
187
|
* `depends` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** name of an attribute we depend on
|
|
186
188
|
* `description` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** human readable
|
|
187
189
|
* `default` **any?** the default value
|
|
@@ -643,6 +645,16 @@ Type: [Token](#token)
|
|
|
643
645
|
|
|
644
646
|
Type: [Token](#token)
|
|
645
647
|
|
|
648
|
+
## Type
|
|
649
|
+
|
|
650
|
+
Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
|
|
651
|
+
|
|
652
|
+
### Properties
|
|
653
|
+
|
|
654
|
+
* `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
|
|
655
|
+
* `primitive` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** 
|
|
656
|
+
* `prepareValue` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** 
|
|
657
|
+
|
|
646
658
|
# install
|
|
647
659
|
|
|
648
660
|
With [npm](http://npmjs.org) do:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pacc",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"ava": "^6.4.1",
|
|
42
|
-
"browser-ava": "^2.3.
|
|
42
|
+
"browser-ava": "^2.3.47",
|
|
43
43
|
"c8": "^10.1.3",
|
|
44
44
|
"documentation": "^14.0.3",
|
|
45
45
|
"semantic-release": "^25.0.2",
|
|
46
46
|
"typescript": "^5.9.3"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
|
-
"node": ">=24.
|
|
49
|
+
"node": ">=24.12.0"
|
|
50
50
|
},
|
|
51
51
|
"repository": {
|
|
52
52
|
"type": "git",
|
|
@@ -348,7 +348,7 @@ export const priority_attribute = {
|
|
|
348
348
|
/**
|
|
349
349
|
* @type {AttributeDefinition}
|
|
350
350
|
*/
|
|
351
|
-
export {
|
|
351
|
+
export const duration_attribute = { ...default_attribute, type: types.duration }
|
|
352
352
|
|
|
353
353
|
/**
|
|
354
354
|
* @type {AttributeDefinition}
|
package/src/time.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const units = {
|
|
2
|
+
ms: 0.001,
|
|
3
|
+
s: 1,
|
|
4
|
+
m: 60,
|
|
5
|
+
h: 3600,
|
|
6
|
+
d: 86400,
|
|
7
|
+
w: 604800
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param {number|string} value
|
|
13
|
+
* @returns {number}
|
|
14
|
+
*/
|
|
15
|
+
export function parseTime(value) {
|
|
16
|
+
if (typeof value === "string") {
|
|
17
|
+
let seconds = 0;
|
|
18
|
+
|
|
19
|
+
for (const match of value.matchAll(/([\d\.\-]+)\s*(\w*)/gi)) {
|
|
20
|
+
const v = parseFloat(match[1]);
|
|
21
|
+
|
|
22
|
+
if (match[2]) {
|
|
23
|
+
seconds += v * units[match[2]];
|
|
24
|
+
} else {
|
|
25
|
+
seconds += v;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return seconds;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return value;
|
|
33
|
+
}
|
package/src/types.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { attributeIterator } from "./attributes.mjs";
|
|
2
|
+
import { parseTime } from "./time.mjs";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @typedef {Object} Type
|
|
@@ -39,8 +40,7 @@ export const types = {
|
|
|
39
40
|
duration: {
|
|
40
41
|
name: "duration",
|
|
41
42
|
primitive: true,
|
|
42
|
-
prepareValue: value =>
|
|
43
|
-
typeof value === "string" ? parseFloat(value) : value
|
|
43
|
+
prepareValue: value => parseTime(value) * 1000
|
|
44
44
|
},
|
|
45
45
|
url: {
|
|
46
46
|
name: "url",
|
|
@@ -166,6 +166,10 @@ export const title_attribute_writable: AttributeDefinition;
|
|
|
166
166
|
* @type {AttributeDefinition}
|
|
167
167
|
*/
|
|
168
168
|
export const priority_attribute: AttributeDefinition;
|
|
169
|
+
/**
|
|
170
|
+
* @type {AttributeDefinition}
|
|
171
|
+
*/
|
|
172
|
+
export const duration_attribute: AttributeDefinition;
|
|
169
173
|
/**
|
|
170
174
|
* @type {AttributeDefinition}
|
|
171
175
|
*/
|
|
@@ -226,4 +230,4 @@ export type AttributeDefinition = {
|
|
|
226
230
|
*/
|
|
227
231
|
additionalValues?: object;
|
|
228
232
|
};
|
|
229
|
-
export { default_attribute as string_attribute, default_attribute_writable as string_attribute_writable, description_attribute as description_attribute_writable, default_attribute as type_attribute, default_attribute_writable as state_attribute_writable, boolean_attribute_writable_true as active_attribute, secret_attribute as username_attribute, secret_attribute as password_attribute, secret_attribute as token_attribute, secret_attribute as certificate_attribute, integer_attribute as count_attribute, integer_attribute_writable as count_attribute_writable, integer_attribute as size_attribute, default_attribute_writable as body_attribute_writable
|
|
233
|
+
export { default_attribute as string_attribute, default_attribute_writable as string_attribute_writable, description_attribute as description_attribute_writable, default_attribute as type_attribute, default_attribute_writable as state_attribute_writable, boolean_attribute_writable_true as active_attribute, secret_attribute as username_attribute, secret_attribute as password_attribute, secret_attribute as token_attribute, secret_attribute as certificate_attribute, integer_attribute as count_attribute, integer_attribute_writable as count_attribute_writable, integer_attribute as size_attribute, default_attribute_writable as body_attribute_writable };
|
package/types/time.d.mts
ADDED