defered-branch 2.2.6 → 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 +8 -8
- package/dist/index.mjs +93 -1
- package/package.json +37 -40
package/dist/index.d.ts
CHANGED
|
@@ -141,9 +141,9 @@ declare class DeferedBranchAll<BranchFn extends AnyFn, NoMatchFn extends AnyFn>
|
|
|
141
141
|
* ## About
|
|
142
142
|
* @package DeferedBranch
|
|
143
143
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
144
|
-
* @version 2.2.
|
|
144
|
+
* @version 2.2.8 (Last Update: 2026.02.17 18:50:28.466)
|
|
145
145
|
* @license MIT
|
|
146
|
-
* @link https://github.com/baendlorel/
|
|
146
|
+
* @link git+https://github.com/baendlorel/kt-packages.git
|
|
147
147
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
148
148
|
* @description Sometimes we need to judge something with multiple cases, but the main job should be done later. So we have Defered Branch!
|
|
149
149
|
* @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
|
|
@@ -182,9 +182,9 @@ declare const deferedBranch: <BranchFn extends AnyFn = AnyFn, NoMatchFn extends
|
|
|
182
182
|
* ## About
|
|
183
183
|
* @package DeferedBranch
|
|
184
184
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
185
|
-
* @version 2.2.
|
|
185
|
+
* @version 2.2.8 (Last Update: 2026.02.17 18:50:28.466)
|
|
186
186
|
* @license MIT
|
|
187
|
-
* @link https://github.com/baendlorel/
|
|
187
|
+
* @link git+https://github.com/baendlorel/kt-packages.git
|
|
188
188
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
189
189
|
* @description Sometimes we need to judge something with multiple cases, but the main job should be done later. So we have Defered Branch!
|
|
190
190
|
* @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
|
|
@@ -216,9 +216,9 @@ declare const deferedBranchDynamic: <BranchFn extends AnyFn = AnyFn, NoMatchFn e
|
|
|
216
216
|
* ## About
|
|
217
217
|
* @package DeferedBranch
|
|
218
218
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
219
|
-
* @version 2.2.
|
|
219
|
+
* @version 2.2.8 (Last Update: 2026.02.17 18:50:28.466)
|
|
220
220
|
* @license MIT
|
|
221
|
-
* @link https://github.com/baendlorel/
|
|
221
|
+
* @link git+https://github.com/baendlorel/kt-packages.git
|
|
222
222
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
223
223
|
* @description Sometimes we need to judge something with multiple cases, but the main job should be done later. So we have Defered Branch!
|
|
224
224
|
* @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
|
|
@@ -257,9 +257,9 @@ declare const deferedBranchAll: <BranchFn extends AnyFn = AnyFn, NoMatchFn exten
|
|
|
257
257
|
* ## About
|
|
258
258
|
* @package DeferedBranch
|
|
259
259
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
260
|
-
* @version 2.2.
|
|
260
|
+
* @version 2.2.8 (Last Update: 2026.02.17 18:50:28.466)
|
|
261
261
|
* @license MIT
|
|
262
|
-
* @link https://github.com/baendlorel/
|
|
262
|
+
* @link git+https://github.com/baendlorel/kt-packages.git
|
|
263
263
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
264
264
|
* @description Sometimes we need to judge something with multiple cases, but the main job should be done later. So we have Defered Branch!
|
|
265
265
|
* @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,93 @@
|
|
|
1
|
-
class t
|
|
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,41 +1,38 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"license": "MIT",
|
|
40
|
-
"devDependencies": {}
|
|
41
|
-
}
|
|
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
|
+
}
|