singleton-pattern 1.2.2 → 1.2.4
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/index.d.ts +2 -2
- package/dist/index.mjs +18 -1
- package/package.json +9 -5
package/dist/index.d.ts
CHANGED
|
@@ -34,9 +34,9 @@ interface SingletonifyOptions {
|
|
|
34
34
|
* ## About
|
|
35
35
|
* @package SingletonPattern
|
|
36
36
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
37
|
-
* @version 1.2.
|
|
37
|
+
* @version 1.2.4 (Last Update: 2026.02.17 18:56:05.498)
|
|
38
38
|
* @license MIT
|
|
39
|
-
* @link https://github.com/baendlorel/
|
|
39
|
+
* @link git+https://github.com/baendlorel/kt-packages.git
|
|
40
40
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
41
41
|
* @description Wrap a class with proxy to make it a safe singleton constructor. Using new Class() will return the same instance.
|
|
42
42
|
* @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
const n=
|
|
1
|
+
const n = new WeakMap, t = new WeakMap;
|
|
2
|
+
|
|
3
|
+
function e(e, c) {
|
|
4
|
+
const o = Object(c), r = o.changeProtoConstructor ?? !0, s = o.onlyOnce ?? !0;
|
|
5
|
+
if (s) {
|
|
6
|
+
const n = t.get(e);
|
|
7
|
+
if (n) return n;
|
|
8
|
+
}
|
|
9
|
+
let a;
|
|
10
|
+
const u = new Proxy(e, {
|
|
11
|
+
construct: (n, t) => (a || (a = new n(...t)), a)
|
|
12
|
+
});
|
|
13
|
+
return r && (u.prototype.constructor = u), s && (n.set(u, e), t.set(e, u)), u;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const c = t => n.get(t);
|
|
17
|
+
|
|
18
|
+
export { c as getSingletonTarget, e as singletonify };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "singleton-pattern",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Kasukabe Tsumugi",
|
|
6
6
|
"email": "futami16237@gmail.com"
|
|
@@ -16,10 +16,11 @@
|
|
|
16
16
|
"files": [
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
|
-
"homepage": "https://github.com/baendlorel/singleton-pattern#readme",
|
|
19
|
+
"homepage": "https://github.com/baendlorel/kt-packages/tree/main/packages/singleton-pattern#readme",
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "https://github.com/baendlorel/
|
|
22
|
+
"url": "git+https://github.com/baendlorel/kt-packages.git",
|
|
23
|
+
"directory": "packages/singleton-pattern"
|
|
23
24
|
},
|
|
24
25
|
"keywords": [
|
|
25
26
|
"deep",
|
|
@@ -39,5 +40,8 @@
|
|
|
39
40
|
"build": "rimraf dist && rollup -c"
|
|
40
41
|
},
|
|
41
42
|
"license": "MIT",
|
|
42
|
-
"devDependencies": {}
|
|
43
|
-
|
|
43
|
+
"devDependencies": {},
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/baendlorel/kt-packages/issues"
|
|
46
|
+
}
|
|
47
|
+
}
|