defered-branch 2.2.5 → 2.2.8

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 CHANGED
@@ -1,3 +1,6 @@
1
+ type AnyFn = (...args: any[]) => any;
2
+ type Predicate<Fn extends AnyFn> = (...args: Parameters<Fn>) => boolean;
3
+
1
4
  declare class DeferedBranch<BranchFn extends AnyFn, NoMatchFn extends AnyFn> {
2
5
  private _branch;
3
6
  /**
@@ -138,12 +141,12 @@ declare class DeferedBranchAll<BranchFn extends AnyFn, NoMatchFn extends AnyFn>
138
141
  * ## About
139
142
  * @package DeferedBranch
140
143
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
141
- * @version 2.2.5 (Last Update: 2025.09.21 19:14:47.820)
144
+ * @version 2.2.8 (Last Update: 2026.02.17 18:50:28.466)
142
145
  * @license MIT
143
- * @link https://github.com/baendlorel/defered-branch
146
+ * @link git+https://github.com/baendlorel/kt-packages.git
144
147
  * @link https://baendlorel.github.io/ Welcome to my site!
145
148
  * @description Sometimes we need to judge something with multiple cases, but the main job should be done later. So we have Defered Branch!
146
- * @copyright Copyright (c) 2025 Kasukabe Tsumugi. All rights reserved.
149
+ * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
147
150
  */
148
151
  declare const deferedBranch: <BranchFn extends AnyFn = AnyFn, NoMatchFn extends AnyFn = AnyFn>() => DeferedBranch<BranchFn, NoMatchFn>;
149
152
  /**
@@ -179,12 +182,12 @@ declare const deferedBranch: <BranchFn extends AnyFn = AnyFn, NoMatchFn extends
179
182
  * ## About
180
183
  * @package DeferedBranch
181
184
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
182
- * @version 2.2.5 (Last Update: 2025.09.21 19:14:47.820)
185
+ * @version 2.2.8 (Last Update: 2026.02.17 18:50:28.466)
183
186
  * @license MIT
184
- * @link https://github.com/baendlorel/defered-branch
187
+ * @link git+https://github.com/baendlorel/kt-packages.git
185
188
  * @link https://baendlorel.github.io/ Welcome to my site!
186
189
  * @description Sometimes we need to judge something with multiple cases, but the main job should be done later. So we have Defered Branch!
187
- * @copyright Copyright (c) 2025 Kasukabe Tsumugi. All rights reserved.
190
+ * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
188
191
  */
189
192
  declare const deferedBranchDynamic: <BranchFn extends AnyFn = AnyFn, NoMatchFn extends AnyFn = AnyFn, ConditionFn extends AnyFn = Predicate<BranchFn>>() => DeferedBranchDynamic<BranchFn, NoMatchFn, ConditionFn>;
190
193
  /**
@@ -213,12 +216,12 @@ declare const deferedBranchDynamic: <BranchFn extends AnyFn = AnyFn, NoMatchFn e
213
216
  * ## About
214
217
  * @package DeferedBranch
215
218
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
216
- * @version 2.2.5 (Last Update: 2025.09.21 19:14:47.820)
219
+ * @version 2.2.8 (Last Update: 2026.02.17 18:50:28.466)
217
220
  * @license MIT
218
- * @link https://github.com/baendlorel/defered-branch
221
+ * @link git+https://github.com/baendlorel/kt-packages.git
219
222
  * @link https://baendlorel.github.io/ Welcome to my site!
220
223
  * @description Sometimes we need to judge something with multiple cases, but the main job should be done later. So we have Defered Branch!
221
- * @copyright Copyright (c) 2025 Kasukabe Tsumugi. All rights reserved.
224
+ * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
222
225
  */
223
226
  declare const deferedBranchAll: <BranchFn extends AnyFn = AnyFn, NoMatchFn extends AnyFn = AnyFn>() => DeferedBranchAll<BranchFn, NoMatchFn>;
224
227
  /**
@@ -254,17 +257,13 @@ declare const deferedBranchAll: <BranchFn extends AnyFn = AnyFn, NoMatchFn exten
254
257
  * ## About
255
258
  * @package DeferedBranch
256
259
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
257
- * @version 2.2.5 (Last Update: 2025.09.21 19:14:47.820)
260
+ * @version 2.2.8 (Last Update: 2026.02.17 18:50:28.466)
258
261
  * @license MIT
259
- * @link https://github.com/baendlorel/defered-branch
262
+ * @link git+https://github.com/baendlorel/kt-packages.git
260
263
  * @link https://baendlorel.github.io/ Welcome to my site!
261
264
  * @description Sometimes we need to judge something with multiple cases, but the main job should be done later. So we have Defered Branch!
262
- * @copyright Copyright (c) 2025 Kasukabe Tsumugi. All rights reserved.
265
+ * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
263
266
  */
264
267
  declare const deferedBranchAllDynamic: <BranchFn extends AnyFn = AnyFn, NoMatchFn extends AnyFn = AnyFn, ConditionFn extends AnyFn = Predicate<BranchFn>>() => DeferedBranchAllDynamic<BranchFn, NoMatchFn, ConditionFn>;
265
268
 
266
269
  export { deferedBranch, deferedBranchAll, deferedBranchAllDynamic, deferedBranchDynamic };
267
-
268
- // # from: src/global.d.ts
269
- type AnyFn = (...args: any[]) => any;
270
- type Predicate<Fn extends AnyFn> = (...args: Parameters<Fn>) => boolean;
package/dist/index.mjs CHANGED
@@ -1 +1,93 @@
1
- class t{t=null;add(t,n){if("function"!=typeof n)throw new TypeError("DeferBranch: branch must be a function");return t&&!this.t&&(this.t=n),this}nomatch(t){if("function"!=typeof t)throw new TypeError("DeferBranch: branch must be a function");return this.t||t(),this}run(...t){if(this.t){const n=this.t.apply(null,t);return this.t=null,n}}}class n{i=[];t=null;h=null;add(t,n){if("function"!=typeof t)throw new TypeError("DeferBranch: condition must be a function");if("function"!=typeof n)throw new TypeError("DeferBranch: branch must be a function");return this.i.push(t,n),this}nomatch(t){if("function"!=typeof t)throw new TypeError("DeferBranch: handler must be a function");return this.h=t,this}predicate(...t){const n=this.i.length;for(let t=0;t<n;t+=2)if(this.i[t]())return void(this.t=this.i[t+1]);this.h&&this.h.apply(this,t)}run(...t){if(this.t){const n=this.t.apply(null,t);return this.t=null,n}}}class r{i=[];o=[];h=null;add(t,n){if("function"!=typeof t)throw new TypeError("DeferBranch: condition must be a function");if("function"!=typeof n)throw new TypeError("DeferBranch: branch must be a function");return this.i.push(t,n),this}nomatch(t){if("function"!=typeof t)throw new TypeError("DeferBranch: handler must be a function");return this.h=t,this}predicate(...t){const n=this.i.length;for(let t=0;t<n;t+=2)this.i[t]()&&this.o.push(this.i[t+1]);this.h&&0===this.o.length&&this.h.apply(this,t)}run(...t){const n=this.o.length;if(0!==n){for(let r=0;r<n;r++)this.o[r].apply(null,t);this.o.length=0}}}class e{o=[];add(t,n){if("function"!=typeof n)throw new TypeError("DeferBranch: branch must be a function");return t&&this.o.push(n),this}nomatch(t){if("function"!=typeof t)throw new TypeError("DeferBranch: branch must be a function");return 0===this.o.length&&t(),this}run(...t){const n=this.o.length;if(0!==n){for(let r=0;r<n;r++)this.o[r].apply(null,t);this.o.length=0}}}const i=()=>new t,h=()=>new n,o=()=>new e,s=()=>new r;export{i as deferedBranch,o as deferedBranchAll,s as deferedBranchAllDynamic,h as deferedBranchDynamic};
1
+ class t {
2
+ t=null;
3
+ add(t, n) {
4
+ if ("function" != typeof n) throw new TypeError("DeferBranch: branch must be a function");
5
+ return t && !this.t && (this.t = n), this;
6
+ }
7
+ nomatch(t) {
8
+ if ("function" != typeof t) throw new TypeError("DeferBranch: branch must be a function");
9
+ return this.t || t(), this;
10
+ }
11
+ run(...t) {
12
+ if (this.t) {
13
+ const n = this.t.apply(null, t);
14
+ return this.t = null, n;
15
+ }
16
+ }
17
+ }
18
+
19
+ class n {
20
+ i=[];
21
+ t=null;
22
+ h=null;
23
+ add(t, n) {
24
+ if ("function" != typeof t) throw new TypeError("DeferBranch: condition must be a function");
25
+ if ("function" != typeof n) throw new TypeError("DeferBranch: branch must be a function");
26
+ return this.i.push(t, n), this;
27
+ }
28
+ nomatch(t) {
29
+ if ("function" != typeof t) throw new TypeError("DeferBranch: handler must be a function");
30
+ return this.h = t, this;
31
+ }
32
+ predicate(...t) {
33
+ const n = this.i.length;
34
+ for (let t = 0; t < n; t += 2) if (this.i[t]()) return void (this.t = this.i[t + 1]);
35
+ this.h && this.h.apply(this, t);
36
+ }
37
+ run(...t) {
38
+ if (this.t) {
39
+ const n = this.t.apply(null, t);
40
+ return this.t = null, n;
41
+ }
42
+ }
43
+ }
44
+
45
+ class r {
46
+ i=[];
47
+ o=[];
48
+ h=null;
49
+ add(t, n) {
50
+ if ("function" != typeof t) throw new TypeError("DeferBranch: condition must be a function");
51
+ if ("function" != typeof n) throw new TypeError("DeferBranch: branch must be a function");
52
+ return this.i.push(t, n), this;
53
+ }
54
+ nomatch(t) {
55
+ if ("function" != typeof t) throw new TypeError("DeferBranch: handler must be a function");
56
+ return this.h = t, this;
57
+ }
58
+ predicate(...t) {
59
+ const n = this.i.length;
60
+ for (let t = 0; t < n; t += 2) this.i[t]() && this.o.push(this.i[t + 1]);
61
+ this.h && 0 === this.o.length && this.h.apply(this, t);
62
+ }
63
+ run(...t) {
64
+ const n = this.o.length;
65
+ if (0 !== n) {
66
+ for (let r = 0; r < n; r++) this.o[r].apply(null, t);
67
+ this.o.length = 0;
68
+ }
69
+ }
70
+ }
71
+
72
+ class e {
73
+ o=[];
74
+ add(t, n) {
75
+ if ("function" != typeof n) throw new TypeError("DeferBranch: branch must be a function");
76
+ return t && this.o.push(n), this;
77
+ }
78
+ nomatch(t) {
79
+ if ("function" != typeof t) throw new TypeError("DeferBranch: branch must be a function");
80
+ return 0 === this.o.length && t(), this;
81
+ }
82
+ run(...t) {
83
+ const n = this.o.length;
84
+ if (0 !== n) {
85
+ for (let r = 0; r < n; r++) this.o[r].apply(null, t);
86
+ this.o.length = 0;
87
+ }
88
+ }
89
+ }
90
+
91
+ const i = () => new t, h = () => new n, o = () => new e, s = () => new r;
92
+
93
+ export { i as deferedBranch, o as deferedBranchAll, s as deferedBranchAllDynamic, h as deferedBranchDynamic };
package/package.json CHANGED
@@ -1,58 +1,38 @@
1
1
  {
2
- "name": "defered-branch",
3
- "version": "2.2.5",
4
- "author": {
5
- "name": "Kasukabe Tsumugi",
6
- "email": "futami16237@gmail.com"
7
- },
8
- "purpose": "npm",
9
- "description": "Sometimes we need to judge something with multiple cases, but the main job should be done later. So we have Defered Branch!",
10
- "description_zh": "有时候我们需要根据多个条件来判断某件事,但主要工作应该在之后完成。所以我们有了延迟分支!",
11
- "type": "module",
12
- "module": "./dist/index.mjs",
13
- "types": "./dist/index.d.ts",
14
- "exports": {
15
- "types": "./dist/index.d.ts",
16
- "import": "./dist/index.mjs",
17
- "default": "./dist/index.mjs"
18
- },
19
- "files": [
20
- "dist"
21
- ],
22
- "homepage": "https://github.com/baendlorel/defered-branch#readme",
23
- "repository": {
24
- "type": "git",
25
- "url": "https://github.com/baendlorel/defered-branch"
26
- },
27
- "keywords": [
28
- "branch",
29
- "assert",
30
- "typescript",
31
- "javascript"
32
- ],
33
- "scripts": {
34
- "test": "clear & vitest",
35
- "lint": "oxlint .",
36
- "cover": "clear & vitest --coverage",
37
- "build": "node ./scripts/rollup.mjs"
38
- },
39
- "license": "MIT",
40
- "devDependencies": {
41
- "@rollup/plugin-alias": "^5.1.1",
42
- "@rollup/plugin-node-resolve": "^16.0.1",
43
- "@rollup/plugin-replace": "^6.0.2",
44
- "@rollup/plugin-terser": "^0.4.4",
45
- "@rollup/plugin-typescript": "^12.1.4",
46
- "@types/node": "^24.5.2",
47
- "@vitest/coverage-v8": "^3.2.4",
48
- "oxlint": "^1.16.0",
49
- "prettier": "^3.6.2",
50
- "rimraf": "^6.0.1",
51
- "rollup": "^4.50.2",
52
- "rollup-plugin-dts": "^6.2.3",
53
- "rollup-plugin-dts-merger": "^1.2.4",
54
- "tslib": "^2.8.1",
55
- "typescript": "^5.9.2",
56
- "vitest": "^3.2.4"
57
- }
58
- }
2
+ "name": "defered-branch",
3
+ "version": "2.2.8",
4
+ "author": {
5
+ "name": "Kasukabe Tsumugi",
6
+ "email": "futami16237@gmail.com"
7
+ },
8
+ "purpose": "npm",
9
+ "description": "Sometimes we need to judge something with multiple cases, but the main job should be done later. So we have Defered Branch!",
10
+ "description_zh": "有时候我们需要根据多个条件来判断某件事,但主要工作应该在之后完成。所以我们有了延迟分支!",
11
+ "type": "module",
12
+ "module": "./dist/index.mjs",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.mjs",
17
+ "default": "./dist/index.mjs"
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "homepage": "https://github.com/baendlorel/kt-packages/tree/main/packages/defered-branch#readme",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/baendlorel/kt-packages.git",
26
+ "directory": "packages/defered-branch"
27
+ },
28
+ "keywords": [
29
+ "branch",
30
+ "assert",
31
+ "typescript",
32
+ "javascript"
33
+ ],
34
+ "license": "MIT",
35
+ "bugs": {
36
+ "url": "https://github.com/baendlorel/kt-packages/issues"
37
+ }
38
+ }