pacc 3.6.0 → 3.6.2

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
@@ -40,15 +40,19 @@ const result = getAttribute({ a: [0,{ b: 4 }]}, "a[1].b");
40
40
  * [Parameters](#parameters-4)
41
41
  * [AttributeDefinition](#attributedefinition)
42
42
  * [Properties](#properties)
43
- * [setAttributes](#setattributes)
43
+ * [prepareAttributesDefinitions](#prepareattributesdefinitions)
44
44
  * [Parameters](#parameters-5)
45
- * [getAttributes](#getattributes)
45
+ * [mergeAttributeDefinitions](#mergeattributedefinitions)
46
46
  * [Parameters](#parameters-6)
47
+ * [setAttributes](#setattributes)
48
+ * [Parameters](#parameters-7)
49
+ * [getAttributes](#getattributes)
50
+ * [Parameters](#parameters-8)
47
51
  * [lookup](#lookup)
48
52
  * [Token](#token)
49
53
  * [Properties](#properties-1)
50
54
  * [createToken](#createtoken)
51
- * [Parameters](#parameters-7)
55
+ * [Parameters](#parameters-9)
52
56
  * [PLUS](#plus)
53
57
  * [MINUS](#minus)
54
58
  * [STAR](#star)
@@ -151,6 +155,27 @@ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Globa
151
155
  * `get` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** get the value can be used to calculate default values
152
156
  * `env` **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)> | [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))?** environment variable(s) used to provide the value
153
157
 
158
+ ## prepareAttributesDefinitions
159
+
160
+ Create attributes from its definition.
161
+
162
+ ### Parameters
163
+
164
+ * `definitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
165
+
166
+ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** attributes
167
+
168
+ ## mergeAttributeDefinitions
169
+
170
+ Merge attribute definitions.
171
+
172
+ ### Parameters
173
+
174
+ * `dest` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** attribute definitions to be used also the merge target
175
+ * `atts` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** attribute definitions to be used
176
+
177
+ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** merged definitions (dest)
178
+
154
179
  ## setAttributes
155
180
 
156
181
  Copies attribute values from a source object into a destination object.
@@ -160,7 +185,7 @@ Copies attribute values from a source object into a destination object.
160
185
  * `object` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** target object to be modified
161
186
  * `source` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** origin of the data to be copied
162
187
  * `definitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** attribute definitions to be used
163
- * `cb` **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** callback to be executed for each copied value
188
+ * `cb` **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** callback to be executed for each copied value
164
189
 
165
190
  ## getAttributes
166
191
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacc",
3
- "version": "3.6.0",
3
+ "version": "3.6.2",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
package/src/multiple.mjs CHANGED
@@ -22,7 +22,9 @@ const types = {
22
22
  base: { name: "base" },
23
23
  string: { name: "string" },
24
24
  number: { name: "number" },
25
- boolean: { name: "boolean" }
25
+ integer: { name: "integer" },
26
+ boolean: { name: "boolean" },
27
+ object: { name: "object" }
26
28
  };
27
29
 
28
30
  /**
@@ -65,11 +67,11 @@ export function mergeAttributeDefinitions(dest, atts) {
65
67
  * @param {Object} object target object to be modified
66
68
  * @param {Object} source origin of the data to be copied
67
69
  * @param {Object} definitions attribute definitions to be used
68
- * @param {function} cb callback to be executed for each copied value
70
+ * @param {function?} cb callback to be executed for each copied value
69
71
  */
70
72
  export function setAttributes(object, source, definitions, cb) {
71
73
  for (const [name, def] of Object.entries(definitions)) {
72
- const value = getAttribute(source, name);
74
+ const value = getAttribute(source, name) ?? def.default;
73
75
  setAttribute(object, name, value);
74
76
  if (cb) {
75
77
  cb(def, name, value);
@@ -16,9 +16,9 @@ export function mergeAttributeDefinitions(dest: any, atts: any): any;
16
16
  * @param {Object} object target object to be modified
17
17
  * @param {Object} source origin of the data to be copied
18
18
  * @param {Object} definitions attribute definitions to be used
19
- * @param {function} cb callback to be executed for each copied value
19
+ * @param {function?} cb callback to be executed for each copied value
20
20
  */
21
- export function setAttributes(object: any, source: any, definitions: any, cb: Function): void;
21
+ export function setAttributes(object: any, source: any, definitions: any, cb: Function | null): void;
22
22
  /**
23
23
  * Retrive attribute values from an object.
24
24
  * @param {Object} object attribute value source