pacc 4.12.0 → 4.12.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
@@ -133,7 +133,7 @@ Create attributes from its definition.
133
133
  ### Parameters
134
134
 
135
135
  * `newDefinitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
136
- * `presentDefinitions` **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))** optional merg in attributes
136
+ * `presentDefinitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** optional merg in attributes
137
137
 
138
138
  Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** attributes
139
139
 
@@ -424,6 +424,7 @@ The name may be a property path like 'a.b.c' or a\[2]
424
424
 
425
425
  * `object` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
426
426
  * `expression` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
427
+ * `definition`  
427
428
 
428
429
  Returns **any** value associated with the given property name
429
430
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacc",
3
- "version": "4.12.0",
3
+ "version": "4.12.2",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -1,21 +1,26 @@
1
1
  const types = {
2
2
  base: { name: "base" },
3
- string: { name: "string" },
4
- number: { name: "number" },
5
- integer: { name: "integer" },
6
- "unsigned-integer": { name: "unsigned-integer" },
3
+ string: { name: "string", extends: "base" },
4
+ number: { name: "number", extends: "base" },
5
+ integer: {
6
+ name: "integer",
7
+ extends: "base",
8
+ convertValue: value => (typeof value === "string" ? parseInt(value) : value)
9
+ },
10
+ "unsigned-integer": { name: "unsigned-integer", extends: "integer" },
7
11
  boolean: {
8
12
  name: "boolean",
13
+ extends: "base",
9
14
  convertValue: value => (!value || value === "0" ? false : true)
10
15
  },
11
- url: { name: "url" },
12
- object: { name: "object" }
16
+ url: { name: "url", extends: "string" },
17
+ object: { name: "object", extends: "base" }
13
18
  };
14
19
 
15
20
  /**
16
21
  * Create attributes from its definition.
17
22
  * @param {Object} newDefinitions
18
- * @param {Object|undefined} presentDefinitions optional merg in attributes
23
+ * @param {Object} [presentDefinitions] optional merg in attributes
19
24
  * @return {Object} attributes
20
25
  */
21
26
  export function prepareAttributesDefinitions(
package/src/module.mjs CHANGED
@@ -3,6 +3,7 @@ export * from "./filter.mjs";
3
3
  export * from "./multiple.mjs";
4
4
  export * from "./attributes.mjs";
5
5
  export * from "./common-attributes.mjs";
6
+ export * from "./properties.mjs";
6
7
  export {
7
8
  setAttribute,
8
9
  getAttribute,
@@ -6,14 +6,14 @@ export function definePropertiesFromAttributes(
6
6
  object,
7
7
  attributes,
8
8
  values,
9
- properties
9
+ properties = {}
10
10
  ) {
11
11
  const applyLater = {};
12
12
 
13
13
  for (const [path, attribute] of attributeIterator(attributes)) {
14
14
  const name = path.join(".");
15
15
 
16
- let value = getAttribute(values, name, attribute);
16
+ let value = getAttribute(values, name, attribute) ?? values?.[name];
17
17
 
18
18
  if (value !== undefined && path.length === 1) {
19
19
  const op = Object.getOwnPropertyDescriptor(
@@ -24,14 +24,10 @@ export function definePropertiesFromAttributes(
24
24
  value = convertValue(value, attribute);
25
25
  const property = properties[name];
26
26
 
27
- console.log(name, value);
28
27
  if (op?.set || property?.set) {
29
28
  applyLater[name] = value;
30
29
  } else {
31
- properties[name] = Object.assign(
32
- { value, writable: attribute.writable },
33
- property
34
- );
30
+ properties[name] = Object.assign({ ...attribute, value }, property);
35
31
  }
36
32
  } else {
37
33
  setAttribute(object, name, value, attribute);
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Create attributes from its definition.
3
3
  * @param {Object} newDefinitions
4
- * @param {Object|undefined} presentDefinitions optional merg in attributes
4
+ * @param {Object} [presentDefinitions] optional merg in attributes
5
5
  * @return {Object} attributes
6
6
  */
7
- export function prepareAttributesDefinitions(newDefinitions: any, presentDefinitions: any | undefined): any;
7
+ export function prepareAttributesDefinitions(newDefinitions: any, presentDefinitions?: any): any;
8
8
  /**
9
9
  * iterate over all attributes.
10
10
  * @param {Object} definition
@@ -3,4 +3,5 @@ export * from "./filter.mjs";
3
3
  export * from "./multiple.mjs";
4
4
  export * from "./attributes.mjs";
5
5
  export * from "./common-attributes.mjs";
6
+ export * from "./properties.mjs";
6
7
  export { setAttribute, getAttribute, getAttributeAndOperator } from "./settergetter.mjs";
@@ -1 +1 @@
1
- export function definePropertiesFromAttributes(object: any, attributes: any, values: any, properties: any): void;
1
+ export function definePropertiesFromAttributes(object: any, attributes: any, values: any, properties?: {}): void;