singleton-pattern 1.2.0 → 1.2.2

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.
Files changed (2) hide show
  1. package/dist/index.d.ts +26 -1
  2. package/package.json +41 -41
package/dist/index.d.ts CHANGED
@@ -1,3 +1,28 @@
1
+ type Class = new (...args: any[]) => any;
2
+
3
+ interface SingletonifyOptions {
4
+ /**
5
+ * Preventing the `.prototype.constructor` from being accessed
6
+ *
7
+ * Default is `true`
8
+ * - use Boolean Evaluation
9
+ * - it is **not recommended** to set this to `false`
10
+ * - if it is falsy, will remain the original constructor unchanged
11
+ * - will change `Origin.prototype.constructor` to the singletonified class
12
+ * - this means Origin.prototype.constructor !== origin
13
+ */
14
+ changeProtoConstructor?: boolean;
15
+
16
+ /**
17
+ * Default is `true`
18
+ * - use Boolean Evaluation
19
+ * - it is **not recommended** to set this to `false`
20
+ * - if it is falsy, it will create a new singletonified class every time and will not cache it
21
+ * - by default, wrap a class multiple times will always return the same singletonified class
22
+ */
23
+ onlyOnce?: boolean;
24
+ }
25
+
1
26
  /**
2
27
  * ## Usage
3
28
  * Just wrap your class with this function to create a new class that always returns the same instance
@@ -9,7 +34,7 @@
9
34
  * ## About
10
35
  * @package SingletonPattern
11
36
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
12
- * @version 1.2.0 (Last Update: 2026.02.13 16:46:16.089)
37
+ * @version 1.2.2 (Last Update: 2026.02.13 17:55:24.162)
13
38
  * @license MIT
14
39
  * @link https://github.com/baendlorel/singleton-pattern
15
40
  * @link https://baendlorel.github.io/ Welcome to my site!
package/package.json CHANGED
@@ -1,43 +1,43 @@
1
1
  {
2
- "name": "singleton-pattern",
3
- "version": "1.2.0",
4
- "author": {
5
- "name": "Kasukabe Tsumugi",
6
- "email": "futami16237@gmail.com"
7
- },
8
- "description": "Wrap a class with proxy to make it a safe singleton constructor. Using new Class() will return the same instance.",
9
- "description_zh": "使用代理包装类以使其成为安全的单例构造函数(原型的构造函数也将被修改)。使用 new Class() 将返回相同的实例",
10
- "type": "module",
11
- "exports": {
12
- "import": "./dist/index.mjs",
13
- "default": "./dist/index.mjs",
14
- "types": "./dist/index.d.ts"
15
- },
16
- "files": [
17
- "dist"
18
- ],
19
- "homepage": "https://github.com/baendlorel/singleton-pattern#readme",
20
- "repository": {
21
- "type": "git",
22
- "url": "https://github.com/baendlorel/singleton-pattern"
23
- },
24
- "keywords": [
25
- "deep",
26
- "clone",
27
- "reflect",
28
- "property",
29
- "path",
30
- "object",
31
- "nested",
32
- "typescript",
33
- "javascript"
34
- ],
35
- "scripts": {
36
- "test": "clear & vitest",
37
- "lint": "oxlint .",
38
- "cover": "clear & vitest --coverage",
39
- "build": "rimraf dist && rollup -c"
40
- },
41
- "license": "MIT",
42
- "devDependencies": {}
2
+ "name": "singleton-pattern",
3
+ "version": "1.2.2",
4
+ "author": {
5
+ "name": "Kasukabe Tsumugi",
6
+ "email": "futami16237@gmail.com"
7
+ },
8
+ "description": "Wrap a class with proxy to make it a safe singleton constructor. Using new Class() will return the same instance.",
9
+ "description_zh": "使用代理包装类以使其成为安全的单例构造函数(原型的构造函数也将被修改)。使用 new Class() 将返回相同的实例",
10
+ "type": "module",
11
+ "exports": {
12
+ "import": "./dist/index.mjs",
13
+ "default": "./dist/index.mjs",
14
+ "types": "./dist/index.d.ts"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "homepage": "https://github.com/baendlorel/singleton-pattern#readme",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/baendlorel/singleton-pattern"
23
+ },
24
+ "keywords": [
25
+ "deep",
26
+ "clone",
27
+ "reflect",
28
+ "property",
29
+ "path",
30
+ "object",
31
+ "nested",
32
+ "typescript",
33
+ "javascript"
34
+ ],
35
+ "scripts": {
36
+ "test": "clear & vitest",
37
+ "lint": "oxlint .",
38
+ "cover": "clear & vitest --coverage",
39
+ "build": "rimraf dist && rollup -c"
40
+ },
41
+ "license": "MIT",
42
+ "devDependencies": {}
43
43
  }