@itrocks/lazy-loading 0.0.5 → 0.0.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/cjs/lazy-loading.js +10 -4
- package/esm/lazy-loading.js +10 -4
- package/package.json +1 -1
package/cjs/lazy-loading.js
CHANGED
|
@@ -23,7 +23,7 @@ function defineCollectionProperty(type, property, builtClass) {
|
|
|
23
23
|
set(value) {
|
|
24
24
|
delete this[property + '_ids'];
|
|
25
25
|
Object.defineProperty(this, property, { configurable: true, enumerable: true, value, writable: true });
|
|
26
|
-
Reflect.
|
|
26
|
+
Reflect.defineMetadata(exports.PROTECT_GET, false, this, property);
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(builtClass.prototype, property, descriptor);
|
|
@@ -41,7 +41,7 @@ function defineObjectProperty(type, property, builtClass) {
|
|
|
41
41
|
set(value) {
|
|
42
42
|
delete this[property + '_id'];
|
|
43
43
|
Object.defineProperty(this, property, { configurable: true, enumerable: true, value, writable: true });
|
|
44
|
-
Reflect.
|
|
44
|
+
Reflect.defineMetadata(exports.PROTECT_GET, false, this, property);
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(builtClass.prototype, property, descriptor);
|
|
@@ -62,11 +62,17 @@ function initClass(classType) {
|
|
|
62
62
|
constructor(...args) {
|
|
63
63
|
super(...args);
|
|
64
64
|
for (const property of properties) {
|
|
65
|
-
|
|
65
|
+
const value = Object.getOwnPropertyDescriptor(this, property)?.value;
|
|
66
|
+
if ((value === undefined) || (Array.isArray(value) && !value.length)) {
|
|
67
|
+
delete this[property];
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
Reflect.defineMetadata(exports.PROTECT_GET, false, this, property);
|
|
71
|
+
}
|
|
66
72
|
}
|
|
67
73
|
}
|
|
68
74
|
})();
|
|
69
|
-
for (const property of
|
|
75
|
+
for (const property of new reflect_1.ReflectClass(classType).properties) {
|
|
70
76
|
const type = property.type;
|
|
71
77
|
if (!type)
|
|
72
78
|
continue;
|
package/esm/lazy-loading.js
CHANGED
|
@@ -20,7 +20,7 @@ function defineCollectionProperty(type, property, builtClass) {
|
|
|
20
20
|
set(value) {
|
|
21
21
|
delete this[property + '_ids'];
|
|
22
22
|
Object.defineProperty(this, property, { configurable: true, enumerable: true, value, writable: true });
|
|
23
|
-
Reflect.
|
|
23
|
+
Reflect.defineMetadata(PROTECT_GET, false, this, property);
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(builtClass.prototype, property, descriptor);
|
|
@@ -38,7 +38,7 @@ function defineObjectProperty(type, property, builtClass) {
|
|
|
38
38
|
set(value) {
|
|
39
39
|
delete this[property + '_id'];
|
|
40
40
|
Object.defineProperty(this, property, { configurable: true, enumerable: true, value, writable: true });
|
|
41
|
-
Reflect.
|
|
41
|
+
Reflect.defineMetadata(PROTECT_GET, false, this, property);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
Object.defineProperty(builtClass.prototype, property, descriptor);
|
|
@@ -59,11 +59,17 @@ export function initClass(classType) {
|
|
|
59
59
|
constructor(...args) {
|
|
60
60
|
super(...args);
|
|
61
61
|
for (const property of properties) {
|
|
62
|
-
|
|
62
|
+
const value = Object.getOwnPropertyDescriptor(this, property)?.value;
|
|
63
|
+
if ((value === undefined) || (Array.isArray(value) && !value.length)) {
|
|
64
|
+
delete this[property];
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
Reflect.defineMetadata(PROTECT_GET, false, this, property);
|
|
68
|
+
}
|
|
63
69
|
}
|
|
64
70
|
}
|
|
65
71
|
})();
|
|
66
|
-
for (const property of
|
|
72
|
+
for (const property of new ReflectClass(classType).properties) {
|
|
67
73
|
const type = property.type;
|
|
68
74
|
if (!type)
|
|
69
75
|
continue;
|
package/package.json
CHANGED