defered-branch 2.2.0 → 2.2.1
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/README.md +11 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,17 @@ For more awesome packages, check out [my homepage💛](https://baendlorel.github
|
|
|
12
12
|
- 🧩 **Flexible**: Works with any function signature
|
|
13
13
|
- 📦 **Generic**: Customizable branch, condition, and nomatch handler types
|
|
14
14
|
|
|
15
|
+
## ⏲️ Change Log (Symplified)
|
|
16
|
+
|
|
17
|
+
### 2.2.1
|
|
18
|
+
|
|
19
|
+
- Fix: Clear matched branch after execution to prevent stale state issues.
|
|
20
|
+
|
|
21
|
+
### 2.2.0
|
|
22
|
+
|
|
23
|
+
- Add `deferedBranchAll` and `deferedBranchAllDynamic` for multi-match scenarios.
|
|
24
|
+
- Fix documentation typos.
|
|
25
|
+
|
|
15
26
|
## 📦 Installation
|
|
16
27
|
|
|
17
28
|
```bash
|
package/dist/index.d.ts
CHANGED
|
@@ -138,7 +138,7 @@ declare class DeferedBranchAll<BranchFn extends AnyFn, NoMatchFn extends AnyFn>
|
|
|
138
138
|
* ## About
|
|
139
139
|
* @package DeferedBranch
|
|
140
140
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
141
|
-
* @version 2.2.
|
|
141
|
+
* @version 2.2.1 (Last Update: 2025.09.21 17:12:09.568)
|
|
142
142
|
* @license MIT
|
|
143
143
|
* @link https://github.com/baendlorel/defered-branch
|
|
144
144
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
@@ -179,7 +179,7 @@ declare const deferedBranch: <BranchFn extends AnyFn = AnyFn, NoMatchFn extends
|
|
|
179
179
|
* ## About
|
|
180
180
|
* @package DeferedBranch
|
|
181
181
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
182
|
-
* @version 2.2.
|
|
182
|
+
* @version 2.2.1 (Last Update: 2025.09.21 17:12:09.568)
|
|
183
183
|
* @license MIT
|
|
184
184
|
* @link https://github.com/baendlorel/defered-branch
|
|
185
185
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
@@ -213,7 +213,7 @@ declare const deferedBranchDynamic: <BranchFn extends AnyFn = AnyFn, NoMatchFn e
|
|
|
213
213
|
* ## About
|
|
214
214
|
* @package DeferedBranch
|
|
215
215
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
216
|
-
* @version 2.2.
|
|
216
|
+
* @version 2.2.1 (Last Update: 2025.09.21 17:12:09.568)
|
|
217
217
|
* @license MIT
|
|
218
218
|
* @link https://github.com/baendlorel/defered-branch
|
|
219
219
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
@@ -254,7 +254,7 @@ declare const deferedBranchAll: <BranchFn extends AnyFn = AnyFn, NoMatchFn exten
|
|
|
254
254
|
* ## About
|
|
255
255
|
* @package DeferedBranch
|
|
256
256
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
257
|
-
* @version 2.2.
|
|
257
|
+
* @version 2.2.1 (Last Update: 2025.09.21 17:12:09.568)
|
|
258
258
|
* @license MIT
|
|
259
259
|
* @link https://github.com/baendlorel/defered-branch
|
|
260
260
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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)
|
|
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};
|