@itrocks/data-to-object 0.0.4 → 0.0.6
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/cjs/data-to-object.d.ts +2 -2
- package/cjs/data-to-object.js +2 -1
- package/package.json +2 -2
package/cjs/data-to-object.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function dataToObject<T extends object>(object: T, data:
|
|
1
|
+
import { RecursiveValueObject } from '@itrocks/request-response';
|
|
2
|
+
export declare function dataToObject<T extends object>(object: T, data: RecursiveValueObject): Promise<T>;
|
package/cjs/data-to-object.js
CHANGED
|
@@ -8,7 +8,7 @@ const transformer_2 = require("@itrocks/transformer");
|
|
|
8
8
|
async function dataToObject(object, data) {
|
|
9
9
|
const properties = new reflect_1.ReflectClass(object).propertyNames;
|
|
10
10
|
for (let fieldName in data) {
|
|
11
|
-
if (fieldName.endsWith('_id')) {
|
|
11
|
+
if (fieldName.endsWith('_id') && !((0, rename_1.toProperty)(fieldName) in object)) {
|
|
12
12
|
fieldName = fieldName.slice(0, -3);
|
|
13
13
|
if (fieldName in data)
|
|
14
14
|
continue;
|
|
@@ -21,5 +21,6 @@ async function dataToObject(object, data) {
|
|
|
21
21
|
continue;
|
|
22
22
|
object[propertyName] = value;
|
|
23
23
|
}
|
|
24
|
+
return object;
|
|
24
25
|
}
|
|
25
26
|
//# sourceMappingURL=data-to-object.js.map
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"description": "Transforms raw string-based data into a business object with type-safe values",
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"typescript": "~5.
|
|
14
|
+
"typescript": "~5.8"
|
|
15
15
|
},
|
|
16
16
|
"engines": {
|
|
17
17
|
"node": ">=18"
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"build": "tsc"
|
|
53
53
|
},
|
|
54
54
|
"types": "./cjs/data-to-object.d.ts",
|
|
55
|
-
"version": "0.0.
|
|
55
|
+
"version": "0.0.6"
|
|
56
56
|
}
|