pacc 6.0.0 → 6.1.1

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 CHANGED
@@ -63,7 +63,6 @@ const result = getAttribute({ a: [0,{ b: 4 }]}, "a[1].b");
63
63
  * [private\_key\_attribute](#private_key_attribute)
64
64
  * [public\_key\_attribute](#public_key_attribute)
65
65
  * [number\_attribute](#number_attribute)
66
- * [number\_attribute](#number_attribute-1)
67
66
  * [number\_attribute\_writable](#number_attribute_writable)
68
67
  * [integer\_attribute](#integer_attribute)
69
68
  * [integer\_attribute](#integer_attribute-1)
@@ -78,6 +77,8 @@ const result = getAttribute({ a: [0,{ b: 4 }]}, "a[1].b");
78
77
  * [id\_attribute](#id_attribute)
79
78
  * [title\_attribute\_writable](#title_attribute_writable)
80
79
  * [priority\_attribute](#priority_attribute)
80
+ * [duration\_attribute](#duration_attribute)
81
+ * [duration\_ms\_attribute](#duration_ms_attribute)
81
82
  * [timeout\_attribute](#timeout_attribute)
82
83
  * [language\_attribute](#language_attribute)
83
84
  * [environmentValues](#environmentvalues)
@@ -101,11 +102,13 @@ const result = getAttribute({ a: [0,{ b: 4 }]}, "a[1].b");
101
102
  * [Parameters](#parameters-11)
102
103
  * [getAttributeAndOperator](#getattributeandoperator)
103
104
  * [Parameters](#parameters-12)
105
+ * [parseTime](#parsetime)
106
+ * [Parameters](#parameters-13)
104
107
  * [lookup](#lookup)
105
108
  * [Token](#token)
106
109
  * [Properties](#properties-1)
107
110
  * [createToken](#createtoken)
108
- * [Parameters](#parameters-13)
111
+ * [Parameters](#parameters-14)
109
112
  * [PLUS](#plus)
110
113
  * [MINUS](#minus)
111
114
  * [STAR](#star)
@@ -317,10 +320,6 @@ Type: [AttributeDefinition](#attributedefinition)
317
320
 
318
321
  Type: [AttributeDefinition](#attributedefinition)
319
322
 
320
- ## number\_attribute
321
-
322
- Type: [AttributeDefinition](#attributedefinition)
323
-
324
323
  ## number\_attribute\_writable
325
324
 
326
325
  Type: [AttributeDefinition](#attributedefinition)
@@ -384,6 +383,14 @@ this defines the order.
384
383
 
385
384
  Type: [AttributeDefinition](#attributedefinition)
386
385
 
386
+ ## duration\_attribute
387
+
388
+ Type: [AttributeDefinition](#attributedefinition)
389
+
390
+ ## duration\_ms\_attribute
391
+
392
+ Type: [AttributeDefinition](#attributedefinition)
393
+
387
394
  ## timeout\_attribute
388
395
 
389
396
  Type: [AttributeDefinition](#attributedefinition)
@@ -511,6 +518,14 @@ The name may be a property path like 'a.b.c <='.
511
518
 
512
519
  Returns **\[any, [Token](#token)]** value associated with the given property name
513
520
 
521
+ ## parseTime
522
+
523
+ ### Parameters
524
+
525
+ * `value` **([number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) | [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))**&#x20;
526
+
527
+ Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**&#x20;
528
+
514
529
  ## lookup
515
530
 
516
531
  Token lookup
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacc",
3
- "version": "6.0.0",
3
+ "version": "6.1.1",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -350,6 +350,11 @@ export const priority_attribute = {
350
350
  */
351
351
  export const duration_attribute = { ...default_attribute, type: types.duration }
352
352
 
353
+ /**
354
+ * @type {AttributeDefinition}
355
+ */
356
+ export const duration_ms_attribute = { ...default_attribute, type: types.duration_ms }
357
+
353
358
  /**
354
359
  * @type {AttributeDefinition}
355
360
  */
package/src/time.mjs CHANGED
@@ -1,16 +1,29 @@
1
1
  const units = {
2
2
  ms: 0.001,
3
+ millisecond: 0.001,
4
+ milliseconds: 0.001,
3
5
  s: 1,
6
+ second: 1,
7
+ seconds: 1,
4
8
  m: 60,
9
+ min: 60,
10
+ minute: 60,
11
+ minutes: 60,
5
12
  h: 3600,
13
+ hour: 3600,
14
+ hours: 3600,
6
15
  d: 86400,
7
- w: 604800
16
+ day: 86400,
17
+ days: 86400,
18
+ w: 604800,
19
+ week: 604800,
20
+ weeks: 604800
8
21
  };
9
22
 
10
23
  /**
11
- *
24
+ * Convert duration formatted string into number of seconds.
12
25
  * @param {number|string} value
13
- * @returns {number}
26
+ * @returns {number} seconds
14
27
  */
15
28
  export function parseTime(value) {
16
29
  if (typeof value === "string") {
package/src/types.mjs CHANGED
@@ -40,6 +40,11 @@ export const types = {
40
40
  duration: {
41
41
  name: "duration",
42
42
  primitive: true,
43
+ prepareValue: value => parseTime(value)
44
+ },
45
+ duration_ms: {
46
+ name: "duration_ms",
47
+ primitive: true,
43
48
  prepareValue: value => parseTime(value) * 1000
44
49
  },
45
50
  url: {
@@ -170,6 +170,10 @@ export const priority_attribute: AttributeDefinition;
170
170
  * @type {AttributeDefinition}
171
171
  */
172
172
  export const duration_attribute: AttributeDefinition;
173
+ /**
174
+ * @type {AttributeDefinition}
175
+ */
176
+ export const duration_ms_attribute: AttributeDefinition;
173
177
  /**
174
178
  * @type {AttributeDefinition}
175
179
  */
package/types/time.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- *
2
+ * Convert duration formatted string into number of seconds.
3
3
  * @param {number|string} value
4
- * @returns {number}
4
+ * @returns {number} seconds
5
5
  */
6
6
  export function parseTime(value: number | string): number;
package/types/types.d.mts CHANGED
@@ -32,6 +32,11 @@ export const types: {
32
32
  primitive: boolean;
33
33
  prepareValue: (value: any) => number;
34
34
  };
35
+ duration_ms: {
36
+ name: string;
37
+ primitive: boolean;
38
+ prepareValue: (value: any) => number;
39
+ };
35
40
  url: {
36
41
  name: string;
37
42
  prepareValue: (value: any) => any;