pacc 3.6.6 → 3.7.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 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.6",
3
+ "version": "3.7.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
package/src/multiple.mjs CHANGED
@@ -3,7 +3,6 @@ import { setAttribute, getAttribute } from "./attribute.mjs";
3
3
  /**
4
4
  * @typedef {Object} AttributeDefinition
5
5
  *
6
- * @property {string} name
7
6
  * @property {string} type
8
7
  * @property {boolean} isKey
9
8
  * @property {boolean} writable
@@ -35,7 +34,6 @@ const types = {
35
34
  */
36
35
  export function prepareAttributesDefinitions(definitions) {
37
36
  for (const [name, d] of Object.entries(definitions)) {
38
- d.name = name;
39
37
  if (d.attributes === undefined) {
40
38
  d.type = types[d.type] || types.base;
41
39
  }
@@ -73,16 +71,19 @@ export function mergeAttributeDefinitions(dest, atts) {
73
71
  */
74
72
  export function setAttributes(object, source, definitions, cb, prefix) {
75
73
  for (let [name, def] of Object.entries(definitions)) {
76
- if(prefix !== undefined) {
74
+ if (prefix !== undefined) {
77
75
  name = prefix + name;
78
76
  }
77
+
78
+ if (def.attributes) {
79
+ setAttributes(object, source, def.attributes, cb, name + ".");
80
+ continue;
81
+ }
82
+
79
83
  let value = getAttribute(source, name);
80
84
 
81
85
  if (value === undefined) {
82
86
  if (def.default === undefined) {
83
- if (def.attributes) {
84
- setAttributes(object, source, def.attributes, cb, name + ".");
85
- }
86
87
  continue;
87
88
  } else {
88
89
  if (getAttribute(object, name) !== undefined) {
@@ -28,7 +28,6 @@ export function setAttributes(object: any, source: any, definitions: any, cb: Fu
28
28
  */
29
29
  export function getAttributes(object: any, definitions: any): any;
30
30
  export type AttributeDefinition = {
31
- name: string;
32
31
  type: string;
33
32
  isKey: boolean;
34
33
  writable: boolean;