defered-branch 1.1.0 → 1.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 CHANGED
@@ -90,10 +90,12 @@ If no branch has been matched when this is called, the `handler` is invoked imme
90
90
 
91
91
  Register a handler to be executed by `run()` if no branch matched. Unlike `nomatch`, this does not run immediately — it defers execution until `run()`.
92
92
 
93
- ### `run(): unknown`
93
+ ### `run(...args: unknown): unknown`
94
94
 
95
95
  Execute the matched branch and return its value. If no branch matched but a `deferedNomatch` handler was set, returns the handler's return value. Returns `undefined` if neither exists.
96
96
 
97
+ `args` will be passed to the matched branch or the `deferedNomatch` handler when they are invoked.
98
+
97
99
  ## Types & Distribution
98
100
 
99
101
  - Types are included (`"types": "./dist/index.d.ts"` in package.json).
package/dist/index.d.ts CHANGED
@@ -27,14 +27,15 @@ declare class DeferBranch {
27
27
  * If some branch matched, return its returnValue
28
28
  * - if no branch matched, return the nomatch handler returnValue
29
29
  * - if no branch matched and no nomatch handler, return undefined
30
+ * @param args arguments to pass to the matched branch or nomatch handler
30
31
  */
31
- run(): unknown;
32
+ run(...args: unknown[]): unknown;
32
33
  }
33
34
  /**
34
35
  * ## About
35
36
  * @package DeferedBranch
36
37
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
37
- * @version 1.1.0 (Last Update: 2025.09.19 07:53:15.059)
38
+ * @version 1.2.1 (Last Update: 2025.09.19 08:02:08.942)
38
39
  * @license MIT
39
40
  * @link https://github.com/baendlorel/defered-branch
40
41
  * @description Sometimes we need to judge something with multiple cases, but the main job should be done later. So we have Defered Branch!
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- class t{t=null;o=null;add(t,n){if("function"!=typeof n)throw new TypeError("Branch must be a function");return t&&(this.t=n),this}nomatch(t){if("function"!=typeof t)throw new TypeError("Branch must be a function");return this.t||t(),this}deferedNomatch(t){if("function"!=typeof t)throw new TypeError("Branch must be a function");return this.o=t,this}run(){return this.t?this.t():this.o?this.o():void 0}}const n=()=>new t;export{n as deferedBranch};
1
+ class t{t=null;o=null;add(t,n){if("function"!=typeof n)throw new TypeError("Branch must be a function");return t&&(this.t=n),this}nomatch(t){if("function"!=typeof t)throw new TypeError("Branch must be a function");return this.t||t(),this}deferedNomatch(t){if("function"!=typeof t)throw new TypeError("Branch must be a function");return this.o=t,this}run(...t){return this.t?this.t(...t):this.o?this.o(...t):void 0}}const n=()=>new t;export{n as deferedBranch};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "defered-branch",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "author": {
5
5
  "name": "Kasukabe Tsumugi",
6
6
  "email": "futami16237@gmail.com"