defered-branch 2.2.0 β†’ 2.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.
package/README.md CHANGED
@@ -4,7 +4,18 @@ A lightweight library providing a if-else like branch, but with deferred executi
4
4
 
5
5
  For more awesome packages, check out [my homepageπŸ’›](https://baendlorel.github.io/?repoType=npm)
6
6
 
7
- ## πŸš€ Features
7
+ - [πŸš€ Features](#features)
8
+ - [⏲️ Change Log](#change-log)
9
+ - [πŸ“¦ Installation](#installation)
10
+ - [🌟 Overview](#overview)
11
+ - [πŸ“š Usage Examples](#usage-examples)
12
+ - [πŸ”§ API Reference](#api-reference)
13
+ - [🧾 Type Annotation](#type-annotation)
14
+ - [πŸ“„ License](#license)
15
+ - [🀝 Contributing](#contributing)
16
+ - [πŸ¦‹ Trivia](#trivia)
17
+
18
+ <h2 id="features">πŸš€ Features</h2>
8
19
 
9
20
  - 🎯 **Four Execution Patterns**: Single/all-match Γ— immediate/dynamic logic
10
21
  - πŸ”’ **Type Safe**: Full TypeScript support with type inference
@@ -12,7 +23,17 @@ For more awesome packages, check out [my homepageπŸ’›](https://baendlorel.github
12
23
  - 🧩 **Flexible**: Works with any function signature
13
24
  - πŸ“¦ **Generic**: Customizable branch, condition, and nomatch handler types
14
25
 
15
- ## πŸ“¦ Installation
26
+ <h2 id="change-log">⏲️ Change Log</h2>
27
+
28
+ - 2.2.1-2.2.2
29
+ - Fix: Clear matched branch after execution to prevent stale state issues.
30
+ - Add index to this document.
31
+
32
+ - 2.2.0
33
+ - Add `deferedBranchAll` and `deferedBranchAllDynamic` for multi-match scenarios.
34
+ - Fix documentation typos.
35
+
36
+ <h2 id="installation">πŸ“¦ Installation</h2>
16
37
 
17
38
  ```bash
18
39
  npm install defered-branch
@@ -20,7 +41,7 @@ npm install defered-branch
20
41
  pnpm add defered-branch
21
42
  ```
22
43
 
23
- ## 🌟 API Overview
44
+ <h2 id="overview">🌟 Overview</h2>
24
45
 
25
46
  ### `deferedBranch` - Single-Match Immediate πŸƒβ€β™‚οΈ
26
47
 
@@ -46,7 +67,7 @@ Reusable branching logic, execute all matches dynamically.
46
67
 
47
68
  **Use cases:** Plugin systems, middleware chains, observer patterns
48
69
 
49
- ## πŸ“š Usage Examples
70
+ <h2 id="usage-examples">Usage Examples</h2>
50
71
 
51
72
  ### Basic `deferedBranch`
52
73
 
@@ -183,7 +204,7 @@ function h<T extends HTMLTag>(
183
204
  }
184
205
  ```
185
206
 
186
- ## πŸ”§ API Reference
207
+ <h2 id="api-reference">πŸ”§ API Reference</h2>
187
208
 
188
209
  ### deferedBranch()
189
210
 
@@ -245,7 +266,7 @@ _Same as deferedBranch_
245
266
 
246
267
  _Same as deferedBranchDynamic_
247
268
 
248
- ## 🧾 Type Annotation
269
+ <h2 id="type-annotation">🧾 Type Annotation</h2>
249
270
 
250
271
  The factory functions `deferedBranch`, `deferedBranchDynamic`, `deferedBranchAll`, and `deferedBranchAllDynamic` are generic helpers. You can provide explicit type parameters to describe the branch function signature and the optional `nomatch` handler.
251
272
 
@@ -302,15 +323,15 @@ calc.predicate();
302
323
  const result = calc.run(2, 3); // typed as number | undefined
303
324
  ```
304
325
 
305
- ## πŸ“„ License
326
+ <h2 id="license">πŸ“„ License</h2>
306
327
 
307
328
  MIT License - see [LICENSE](LICENSE) file for details.
308
329
 
309
- ## 🀝 Contributing
330
+ <h2 id="contributing">🀝 Contributing</h2>
310
331
 
311
332
  Contributions are welcome! Please feel free to submit issues and pull requests.
312
333
 
313
- ## πŸ¦‹ Trivia
334
+ <h2 id="trivia">πŸ¦‹ Trivia</h2>
314
335
 
315
336
  [**KT.js**](https://www.npmjs.com/package/kt.js) is the reason of this package's birth. It uses `deferedBranchDynamic` internally to handle attribute and content processing in a clean, reusable way.
316
337
 
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.0 (Last Update: 2025.09.21 16:49:49.136)
141
+ * @version 2.2.2 (Last Update: 2025.09.21 17:25:17.771)
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.0 (Last Update: 2025.09.21 16:49:49.136)
182
+ * @version 2.2.2 (Last Update: 2025.09.21 17:25:17.771)
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.0 (Last Update: 2025.09.21 16:49:49.136)
216
+ * @version 2.2.2 (Last Update: 2025.09.21 17:25:17.771)
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.0 (Last Update: 2025.09.21 16:49:49.136)
257
+ * @version 2.2.2 (Last Update: 2025.09.21 17:25:17.771)
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)return this.t.apply(null,t)}}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)return this.t.apply(null,t)}}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)}}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)}}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{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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "defered-branch",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "author": {
5
5
  "name": "Kasukabe Tsumugi",
6
6
  "email": "futami16237@gmail.com"