@itrocks/lazy-loading 0.0.6 → 0.0.8
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 +5 -5
- package/esm/lazy-loading.js +5 -5
- package/package.json +1 -1
package/cjs/lazy-loading.js
CHANGED
|
@@ -15,13 +15,13 @@ function defineCollectionProperty(type, property, builtClass) {
|
|
|
15
15
|
enumerable: true,
|
|
16
16
|
async get() {
|
|
17
17
|
const elementType = type.elementType;
|
|
18
|
-
const ids = this[property + '
|
|
18
|
+
const ids = this[property + 'Ids'];
|
|
19
19
|
return this[property] = ids
|
|
20
20
|
? await (0, storage_1.dataSource)().readMultiple(elementType, ids)
|
|
21
21
|
: await (0, storage_1.dataSource)().readCollection(this, property, elementType);
|
|
22
22
|
},
|
|
23
23
|
set(value) {
|
|
24
|
-
delete this[property + '
|
|
24
|
+
delete this[property + 'Ids'];
|
|
25
25
|
Object.defineProperty(this, property, { configurable: true, enumerable: true, value, writable: true });
|
|
26
26
|
Reflect.defineMetadata(exports.PROTECT_GET, false, this, property);
|
|
27
27
|
}
|
|
@@ -35,11 +35,11 @@ function defineObjectProperty(type, property, builtClass) {
|
|
|
35
35
|
configurable: true,
|
|
36
36
|
enumerable: true,
|
|
37
37
|
async get() {
|
|
38
|
-
const id = this[property + '
|
|
38
|
+
const id = this[property + 'Id'];
|
|
39
39
|
return this[property] = id ? await (0, storage_1.dataSource)().read(type, id) : undefined;
|
|
40
40
|
},
|
|
41
41
|
set(value) {
|
|
42
|
-
delete this[property + '
|
|
42
|
+
delete this[property + 'Id'];
|
|
43
43
|
Object.defineProperty(this, property, { configurable: true, enumerable: true, value, writable: true });
|
|
44
44
|
Reflect.defineMetadata(exports.PROTECT_GET, false, this, property);
|
|
45
45
|
}
|
|
@@ -72,7 +72,7 @@ function initClass(classType) {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
})();
|
|
75
|
-
for (const property of
|
|
75
|
+
for (const property of new reflect_1.ReflectClass(classType).properties) {
|
|
76
76
|
const type = property.type;
|
|
77
77
|
if (!type)
|
|
78
78
|
continue;
|
package/esm/lazy-loading.js
CHANGED
|
@@ -12,13 +12,13 @@ function defineCollectionProperty(type, property, builtClass) {
|
|
|
12
12
|
enumerable: true,
|
|
13
13
|
async get() {
|
|
14
14
|
const elementType = type.elementType;
|
|
15
|
-
const ids = this[property + '
|
|
15
|
+
const ids = this[property + 'Ids'];
|
|
16
16
|
return this[property] = ids
|
|
17
17
|
? await dataSource().readMultiple(elementType, ids)
|
|
18
18
|
: await dataSource().readCollection(this, property, elementType);
|
|
19
19
|
},
|
|
20
20
|
set(value) {
|
|
21
|
-
delete this[property + '
|
|
21
|
+
delete this[property + 'Ids'];
|
|
22
22
|
Object.defineProperty(this, property, { configurable: true, enumerable: true, value, writable: true });
|
|
23
23
|
Reflect.defineMetadata(PROTECT_GET, false, this, property);
|
|
24
24
|
}
|
|
@@ -32,11 +32,11 @@ function defineObjectProperty(type, property, builtClass) {
|
|
|
32
32
|
configurable: true,
|
|
33
33
|
enumerable: true,
|
|
34
34
|
async get() {
|
|
35
|
-
const id = this[property + '
|
|
35
|
+
const id = this[property + 'Id'];
|
|
36
36
|
return this[property] = id ? await dataSource().read(type, id) : undefined;
|
|
37
37
|
},
|
|
38
38
|
set(value) {
|
|
39
|
-
delete this[property + '
|
|
39
|
+
delete this[property + 'Id'];
|
|
40
40
|
Object.defineProperty(this, property, { configurable: true, enumerable: true, value, writable: true });
|
|
41
41
|
Reflect.defineMetadata(PROTECT_GET, false, this, property);
|
|
42
42
|
}
|
|
@@ -69,7 +69,7 @@ export function initClass(classType) {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
})();
|
|
72
|
-
for (const property of
|
|
72
|
+
for (const property of new ReflectClass(classType).properties) {
|
|
73
73
|
const type = property.type;
|
|
74
74
|
if (!type)
|
|
75
75
|
continue;
|
package/package.json
CHANGED