@itrocks/lazy-loading 0.0.1 → 0.0.3
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 +2 -0
- package/cjs/lazy-loading.d.ts +1 -0
- package/cjs/lazy-loading.js +21 -18
- package/esm/lazy-loading.d.ts +1 -0
- package/esm/lazy-loading.js +20 -18
- package/package.json +11 -3
package/README.md
CHANGED
package/cjs/lazy-loading.d.ts
CHANGED
package/cjs/lazy-loading.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PROTECT_GET = void 0;
|
|
4
4
|
exports.initClass = initClass;
|
|
5
|
+
exports.initLazyLoading = initLazyLoading;
|
|
5
6
|
const class_type_1 = require("@itrocks/class-type");
|
|
6
7
|
const property_type_1 = require("@itrocks/property-type");
|
|
7
8
|
const reflect_1 = require("@itrocks/reflect");
|
|
@@ -78,22 +79,24 @@ function initClass(classType) {
|
|
|
78
79
|
}
|
|
79
80
|
return properties.length ? BuiltClass : undefined;
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
Module.prototype.require
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
module
|
|
82
|
+
function initLazyLoading() {
|
|
83
|
+
const Module = require('module');
|
|
84
|
+
const superRequire = Module.prototype.require;
|
|
85
|
+
Module.prototype.require = function () {
|
|
86
|
+
const original = superRequire.call(this, ...arguments);
|
|
87
|
+
let module;
|
|
88
|
+
for (const [name, type] of Object.entries(original)) {
|
|
89
|
+
if (!(0, class_type_1.isAnyType)(type))
|
|
90
|
+
continue;
|
|
91
|
+
const withORM = initClass(type);
|
|
92
|
+
if (!withORM)
|
|
93
|
+
continue;
|
|
94
|
+
if (!module) {
|
|
95
|
+
module = { ...original };
|
|
96
|
+
}
|
|
97
|
+
// @ts-ignore TS18048 but module is always initialized
|
|
98
|
+
module[name] = withORM;
|
|
94
99
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return module ?? original;
|
|
99
|
-
};
|
|
100
|
+
return module ?? original;
|
|
101
|
+
};
|
|
102
|
+
}
|
package/esm/lazy-loading.d.ts
CHANGED
package/esm/lazy-loading.js
CHANGED
|
@@ -76,22 +76,24 @@ export function initClass(classType) {
|
|
|
76
76
|
}
|
|
77
77
|
return properties.length ? BuiltClass : undefined;
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
Module.prototype.require
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
module
|
|
79
|
+
export function initLazyLoading() {
|
|
80
|
+
const Module = require('module');
|
|
81
|
+
const superRequire = Module.prototype.require;
|
|
82
|
+
Module.prototype.require = function () {
|
|
83
|
+
const original = superRequire.call(this, ...arguments);
|
|
84
|
+
let module;
|
|
85
|
+
for (const [name, type] of Object.entries(original)) {
|
|
86
|
+
if (!isAnyType(type))
|
|
87
|
+
continue;
|
|
88
|
+
const withORM = initClass(type);
|
|
89
|
+
if (!withORM)
|
|
90
|
+
continue;
|
|
91
|
+
if (!module) {
|
|
92
|
+
module = { ...original };
|
|
93
|
+
}
|
|
94
|
+
// @ts-ignore TS18048 but module is always initialized
|
|
95
|
+
module[name] = withORM;
|
|
92
96
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return module ?? original;
|
|
97
|
-
};
|
|
97
|
+
return module ?? original;
|
|
98
|
+
};
|
|
99
|
+
}
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"@itrocks/storage": "latest",
|
|
11
11
|
"@itrocks/store": "latest"
|
|
12
12
|
},
|
|
13
|
-
"description": "",
|
|
13
|
+
"description": "Integrates lazy loading for objects and collections in TypeScript classes",
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@types/node": "^22.10",
|
|
16
16
|
"typescript": "^5.6"
|
|
@@ -32,7 +32,15 @@
|
|
|
32
32
|
"homepage": "https://it.rocks",
|
|
33
33
|
"keywords": [
|
|
34
34
|
"backend",
|
|
35
|
-
"
|
|
35
|
+
"collection",
|
|
36
|
+
"it.rocks",
|
|
37
|
+
"lazy",
|
|
38
|
+
"lazy-loading",
|
|
39
|
+
"loading",
|
|
40
|
+
"object",
|
|
41
|
+
"orm",
|
|
42
|
+
"reflect",
|
|
43
|
+
"reflection"
|
|
36
44
|
],
|
|
37
45
|
"license": "ISC",
|
|
38
46
|
"name": "@itrocks/lazy-loading",
|
|
@@ -46,5 +54,5 @@
|
|
|
46
54
|
"build:esm": "tsc -p tsconfig.esm.json && node esm/esm"
|
|
47
55
|
},
|
|
48
56
|
"types": "./esm/lazy-loading.d.ts",
|
|
49
|
-
"version": "0.0.
|
|
57
|
+
"version": "0.0.3"
|
|
50
58
|
}
|