pacc 3.6.5 → 3.6.7

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
@@ -186,6 +186,7 @@ Copies attribute values from a source object into a destination object.
186
186
  * `source` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** origin of the data to be copied
187
187
  * `definitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** attribute definitions to be used
188
188
  * `cb` **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** callback to be executed for each copied value
189
+ * `prefix` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** name parefix
189
190
 
190
191
  ## getAttributes
191
192
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacc",
3
- "version": "3.6.5",
3
+ "version": "3.6.7",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
package/src/multiple.mjs CHANGED
@@ -69,15 +69,23 @@ export function mergeAttributeDefinitions(dest, atts) {
69
69
  * @param {Object} source origin of the data to be copied
70
70
  * @param {Object} definitions attribute definitions to be used
71
71
  * @param {function?} cb callback to be executed for each copied value
72
+ * @param {string?} prefix name parefix
72
73
  */
73
- export function setAttributes(object, source, definitions, cb) {
74
- for (const [name, def] of Object.entries(definitions)) {
74
+ export function setAttributes(object, source, definitions, cb, prefix) {
75
+ for (let [name, def] of Object.entries(definitions)) {
76
+ if (prefix !== undefined) {
77
+ name = prefix + name;
78
+ }
79
+
80
+ if (def.attributes) {
81
+ setAttributes(object, source, def.attributes, cb, name + ".");
82
+ continue;
83
+ }
84
+
75
85
  let value = getAttribute(source, name);
86
+
76
87
  if (value === undefined) {
77
88
  if (def.default === undefined) {
78
- if (def.attributes) {
79
- object[name] = {};
80
- }
81
89
  continue;
82
90
  } else {
83
91
  if (getAttribute(object, name) !== undefined) {
@@ -17,8 +17,9 @@ export function mergeAttributeDefinitions(dest: any, atts: any): any;
17
17
  * @param {Object} source origin of the data to be copied
18
18
  * @param {Object} definitions attribute definitions to be used
19
19
  * @param {function?} cb callback to be executed for each copied value
20
+ * @param {string?} prefix name parefix
20
21
  */
21
- export function setAttributes(object: any, source: any, definitions: any, cb: Function | null): void;
22
+ export function setAttributes(object: any, source: any, definitions: any, cb: Function | null, prefix: string | null): void;
22
23
  /**
23
24
  * Retrive attribute values from an object.
24
25
  * @param {Object} object attribute value source