pacc 4.22.0 → 4.23.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/package.json +1 -1
- package/src/attributes.mjs +6 -6
- package/src/properties.mjs +2 -2
- package/src/settergetter.mjs +2 -2
- package/types/attributes.d.mts +4 -4
package/package.json
CHANGED
package/src/attributes.mjs
CHANGED
|
@@ -9,19 +9,19 @@ export const types = {
|
|
|
9
9
|
number: {
|
|
10
10
|
name: "number",
|
|
11
11
|
extends: "base",
|
|
12
|
-
|
|
12
|
+
prepareValue: (value, attribute) =>
|
|
13
13
|
typeof value === "string" ? parseFloat(value) : value
|
|
14
14
|
},
|
|
15
15
|
boolean: {
|
|
16
16
|
name: "boolean",
|
|
17
17
|
extends: "base",
|
|
18
|
-
|
|
18
|
+
prepareValue: (value, attribute) => (!value || value === "0" ? false : true)
|
|
19
19
|
},
|
|
20
20
|
|
|
21
21
|
integer: {
|
|
22
22
|
name: "integer",
|
|
23
23
|
extends: "base",
|
|
24
|
-
|
|
24
|
+
prepareValue: (value, attribute) =>
|
|
25
25
|
typeof value === "string" ? parseInt(value) : value
|
|
26
26
|
},
|
|
27
27
|
"unsigned-integer": { name: "unsigned-integer", extends: "integer" },
|
|
@@ -91,9 +91,9 @@ export function* attributeIterator(definition, path = []) {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
export function
|
|
95
|
-
if (attribute?.type?.
|
|
96
|
-
return attribute.type.
|
|
94
|
+
export function prepareValue(value, attribute) {
|
|
95
|
+
if (attribute?.type?.prepareValue) {
|
|
96
|
+
return attribute.type.prepareValue(value, attribute);
|
|
97
97
|
}
|
|
98
98
|
return value;
|
|
99
99
|
}
|
package/src/properties.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { attributeIterator } from "./attributes.mjs";
|
|
2
2
|
import { getAttribute, setAttribute } from "./settergetter.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { prepareValue } from "./attributes.mjs";
|
|
4
4
|
|
|
5
5
|
export function definePropertiesFromAttributes(
|
|
6
6
|
object,
|
|
@@ -22,7 +22,7 @@ export function definePropertiesFromAttributes(
|
|
|
22
22
|
name
|
|
23
23
|
);
|
|
24
24
|
|
|
25
|
-
value =
|
|
25
|
+
value = prepareValue(value, attribute);
|
|
26
26
|
|
|
27
27
|
const property = properties[name];
|
|
28
28
|
|
package/src/settergetter.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
STAR
|
|
17
17
|
} from "./tokens.mjs";
|
|
18
18
|
import { parse } from "./expression.mjs";
|
|
19
|
-
import {
|
|
19
|
+
import { prepareValue } from "./attributes.mjs";
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Set object attribute.
|
|
@@ -48,7 +48,7 @@ export function setAttribute(object, expression, value, definition) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
if (anchor) {
|
|
51
|
-
anchor[anchorKey] =
|
|
51
|
+
anchor[anchorKey] = prepareValue(value, definition);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
package/types/attributes.d.mts
CHANGED
|
@@ -11,7 +11,7 @@ export function prepareAttributesDefinitions(newDefinitions: any, presentDefinit
|
|
|
11
11
|
* @param {string[]} path
|
|
12
12
|
*/
|
|
13
13
|
export function attributeIterator(definition: any, path?: string[]): any;
|
|
14
|
-
export function
|
|
14
|
+
export function prepareValue(value: any, attribute: any): any;
|
|
15
15
|
export const baseTypes: Set<string>;
|
|
16
16
|
export const types: {
|
|
17
17
|
base: {
|
|
@@ -24,17 +24,17 @@ export const types: {
|
|
|
24
24
|
number: {
|
|
25
25
|
name: string;
|
|
26
26
|
extends: string;
|
|
27
|
-
|
|
27
|
+
prepareValue: (value: any, attribute: any) => any;
|
|
28
28
|
};
|
|
29
29
|
boolean: {
|
|
30
30
|
name: string;
|
|
31
31
|
extends: string;
|
|
32
|
-
|
|
32
|
+
prepareValue: (value: any, attribute: any) => boolean;
|
|
33
33
|
};
|
|
34
34
|
integer: {
|
|
35
35
|
name: string;
|
|
36
36
|
extends: string;
|
|
37
|
-
|
|
37
|
+
prepareValue: (value: any, attribute: any) => any;
|
|
38
38
|
};
|
|
39
39
|
"unsigned-integer": {
|
|
40
40
|
name: string;
|