@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 CHANGED
@@ -5,3 +5,5 @@
5
5
  [![discord](https://img.shields.io/discord/1314141024020467782?color=7289da&label=discord&logo=discord&logoColor=white)](https://25.re/ditr)
6
6
 
7
7
  # lazy-loading
8
+
9
+ Integrates lazy loading for objects and collections in TypeScript classes.
@@ -4,3 +4,4 @@ export type PropertyDescriptorWithProtectGet = PropertyDescriptor & ThisType<any
4
4
  [PROTECT_GET]?: true;
5
5
  };
6
6
  export declare function initClass<T extends object>(classType: Type<T>): Type<T> | undefined;
7
+ export declare function initLazyLoading(): void;
@@ -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
- const Module = require('module');
82
- const superRequire = Module.prototype.require;
83
- Module.prototype.require = function () {
84
- const original = superRequire.call(this, ...arguments);
85
- let module;
86
- for (const [name, type] of Object.entries(original)) {
87
- if (!(0, class_type_1.isAnyType)(type))
88
- continue;
89
- const withORM = initClass(type);
90
- if (!withORM)
91
- continue;
92
- if (!module) {
93
- module = { ...original };
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
- // @ts-ignore TS18048 but module is always initialized
96
- module[name] = withORM;
97
- }
98
- return module ?? original;
99
- };
100
+ return module ?? original;
101
+ };
102
+ }
@@ -4,3 +4,4 @@ export type PropertyDescriptorWithProtectGet = PropertyDescriptor & ThisType<any
4
4
  [PROTECT_GET]?: true;
5
5
  };
6
6
  export declare function initClass<T extends object>(classType: Type<T>): Type<T> | undefined;
7
+ export declare function initLazyLoading(): void;
@@ -76,22 +76,24 @@ export function initClass(classType) {
76
76
  }
77
77
  return properties.length ? BuiltClass : undefined;
78
78
  }
79
- const Module = require('module');
80
- const superRequire = Module.prototype.require;
81
- Module.prototype.require = function () {
82
- const original = superRequire.call(this, ...arguments);
83
- let module;
84
- for (const [name, type] of Object.entries(original)) {
85
- if (!isAnyType(type))
86
- continue;
87
- const withORM = initClass(type);
88
- if (!withORM)
89
- continue;
90
- if (!module) {
91
- module = { ...original };
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
- // @ts-ignore TS18048 but module is always initialized
94
- module[name] = withORM;
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
- "it.rocks"
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.1"
57
+ "version": "0.0.3"
50
58
  }