defered-branch 1.0.0 → 1.0.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/dist/index.d.ts CHANGED
@@ -1,38 +1,40 @@
1
1
  declare class DeferBranch {
2
- /**
3
- * Add a new entry
4
- * - will **override** the previous matched branch
5
- * @param condition the condition to match
6
- * @param branch the branch to run when matched
7
- * @returns this
8
- */
9
- add(condition: boolean, branch: Fn): DeferBranch;
10
- /**
11
- * When no branch matched, run this handler
12
- * @param handler handle the exhausted case
13
- * @returns this
14
- */
15
- nomatch(handler: Fn): DeferBranch;
16
- /**
17
- * If some branch matched, return its returnValue
18
- * - if no branch matched, return the nomatch handler returnValue
19
- * - if no branch matched and no nomatch handler, return undefined
20
- */
21
- run(): unknown;
2
+ private _branch;
3
+ private _nomatchHandler;
4
+ /**
5
+ * Add a new entry
6
+ * - will **override** the previous matched branch
7
+ * @param condition the condition to match
8
+ * @param branch the branch to run when matched
9
+ * @returns this
10
+ */
11
+ add(condition: boolean, branch: Fn): DeferBranch;
12
+ /**
13
+ * When no branch matched, run this handler
14
+ * @param handler handle the exhausted case
15
+ * @returns this
16
+ */
17
+ nomatch(handler: Fn): DeferBranch;
18
+ /**
19
+ * If some branch matched, return its returnValue
20
+ * - if no branch matched, return the nomatch handler returnValue
21
+ * - if no branch matched and no nomatch handler, return undefined
22
+ */
23
+ run(): unknown;
22
24
  }
23
25
  /**
24
26
  * ## About
25
27
  * @package DeferedBranch
26
28
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
27
- * @version 1.0.0 (Last Update: 2025.09.19 07:27:30.174)
29
+ * @version 1.0.1 (Last Update: 2025.09.19 07:33:04.605)
28
30
  * @license MIT
29
31
  * @link https://github.com/baendlorel/defered-branch
30
32
  * @description Sometimes we need to judge something with multiple cases, but the main job should be done later. So we have Defered Branch!
31
33
  * @copyright Copyright (c) 2025 Kasukabe Tsumugi. All rights reserved.
32
34
  */
33
- declare const deferBranch: () => DeferBranch;
35
+ declare const deferedBranch: () => DeferBranch;
34
36
 
35
- export { deferBranch };
37
+ export { deferedBranch };
36
38
 
37
39
  // # from: src/global.d.ts
38
40
  type Fn = (...args: unknown[]) => unknown;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- class t{t=null;h=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.h=t,this}run(){return this.t?this.t():this.h?this.h():void 0}}const n=()=>new t;export{n as deferBranch};
1
+ class t{t=null;h=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.h=t,this}run(){return this.t?this.t():this.h?this.h():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.0.0",
3
+ "version": "1.0.1",
4
4
  "author": {
5
5
  "name": "Kasukabe Tsumugi",
6
6
  "email": "futami16237@gmail.com"