@driveflux/singleton 1.3.0 → 1.4.0
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/dist/cjs/package.json +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -5,5 +5,7 @@ type SingletonMap = Map<string, any>;
|
|
|
5
5
|
export declare const singletonMap: SingletonMap;
|
|
6
6
|
export declare function singleton<T>(name: string, object: T, force?: boolean): T;
|
|
7
7
|
export declare function singleton<T>(name: string): T | null;
|
|
8
|
+
export declare function instantiateSingleton<T>(name: string, init: () => T, force?: boolean): T;
|
|
9
|
+
export declare function instantiateSingleton<T>(name: string): T | null;
|
|
8
10
|
export {};
|
|
9
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IAEd,IAAI,yBAAyB,EAAE,YAAY,CAAA;CAC3C;AAED,KAAK,YAAY,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAOpC,eAAO,MAAM,YAAY,cAAuC,CAAA;AAEhE,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,CAAC,CAAA;AACzE,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IAEd,IAAI,yBAAyB,EAAE,YAAY,CAAA;CAC3C;AAED,KAAK,YAAY,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAOpC,eAAO,MAAM,YAAY,cAAuC,CAAA;AAEhE,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,CAAC,CAAA;AACzE,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAAA;AAuBpD,wBAAgB,oBAAoB,CAAC,CAAC,EACrC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,EACb,KAAK,CAAC,EAAE,OAAO,GACb,CAAC,CAAA;AACJ,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -16,3 +16,10 @@ if (process.env.SINGLETON_DEBUG === 'true') {
|
|
|
16
16
|
console.log('Singletons', (_globalThis___globalSingletonProvider = globalThis.__globalSingletonProvider) === null || _globalThis___globalSingletonProvider === void 0 ? void 0 : _globalThis___globalSingletonProvider.size, globalThis.__globalSingletonProvider.keys());
|
|
17
17
|
}, 1000);
|
|
18
18
|
}
|
|
19
|
+
export function instantiateSingleton(name, init) {
|
|
20
|
+
var force = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
21
|
+
if (singletonMap.has(name) && !force) {
|
|
22
|
+
return singletonMap.get(name);
|
|
23
|
+
}
|
|
24
|
+
return singletonMap.set(name, init === null || init === void 0 ? void 0 : init()).get(name);
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driveflux/singleton",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@driveflux/fab": "2.3.0",
|
|
16
16
|
"@driveflux/tsconfig": "1.3.0",
|
|
17
|
-
"@swc/cli": "
|
|
18
|
-
"@swc/core": "1.7.
|
|
19
|
-
"@types/lodash": "^4.17.
|
|
20
|
-
"@types/node": "^
|
|
21
|
-
"del-cli": "^
|
|
22
|
-
"typescript": "^5.
|
|
17
|
+
"@swc/cli": "0.4.1-nightly.20240914",
|
|
18
|
+
"@swc/core": "1.7.39",
|
|
19
|
+
"@types/lodash": "^4.17.12",
|
|
20
|
+
"@types/node": "^22.7.8",
|
|
21
|
+
"del-cli": "^6.0.0",
|
|
22
|
+
"typescript": "^5.6.3"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "fab",
|