klubok 0.5.0 → 0.5.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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Do notation pipes for Promise-based or pure functions which easy to mock <br/>
|
|
6
6
|
Inspired by fp-ts/Effect `bind` Do-notation, but much more small and simple <br/>
|
|
7
|
-
Primarly created for easy mocking of functions, which allows to write tons of unit tests
|
|
7
|
+
Primarly created for easy mocking of functions, which allows to write tons of unit tests using London school approach
|
|
8
8
|
|
|
9
9
|
## Example
|
|
10
10
|
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ type KeyedFunction<K extends string, F extends Function> = F & {
|
|
|
7
7
|
export declare const pure: <K extends string, C, R>(key: K, fn: (ctx: C) => R) => KeyedFunction<K, (ctx: C) => R>;
|
|
8
8
|
export declare const eff: <K extends string, C, R>(key: K, fn: (ctx: C) => Promise<R>) => KeyedFunction<K, (ctx: C) => Promise<R>>;
|
|
9
9
|
export declare const mut: <K extends string, C, R>(fn: KeyedFunction<K, (ctx: C) => R>) => KeyedFunction<K, (ctx: C) => R>;
|
|
10
|
-
export declare const exitIfNullable: <K extends string, C, R>(fn: KeyedFunction<K, (ctx: C) => R>) => KeyedFunction<K, (ctx: C) => NonNullable<R>>;
|
|
10
|
+
export declare const exitIfNullable: <K extends string, C, R>(fn: KeyedFunction<K, (ctx: C) => Promise<R> | R>) => KeyedFunction<K, (ctx: C) => NonNullable<R>>;
|
|
11
11
|
export declare const onError: <K extends string, C, R>(key: K, fn: (ctx: C) => R) => KeyedFunction<K, (ctx: C) => R>;
|
|
12
12
|
export declare function klubok<K1 extends string, C extends object, R1>(fn1: KeyedFunction<K1, (ctx: C) => Promise<R1> | R1>): (ctx: C, mock?: {
|
|
13
13
|
[k in K1]?: R1 | ((ctx: C) => R1 | Promise<R1>);
|
package/dist/index.js
CHANGED
|
@@ -69,7 +69,7 @@ function klubok(...fns) {
|
|
|
69
69
|
}
|
|
70
70
|
catch (error) {
|
|
71
71
|
await onError?.({ ...ctx, $error: error });
|
|
72
|
-
if (error instanceof Error) {
|
|
72
|
+
if (error instanceof Error && !error.isApproved) {
|
|
73
73
|
error.stack += '\ncontext: ' + (0, node_util_1.inspect)(ctx);
|
|
74
74
|
}
|
|
75
75
|
throw error;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "klubok",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Do notation pipes for Promise-based or pure functions which easy to mock",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"author": "Vladislav Botvin",
|
|
35
35
|
"license": "MIT",
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@types/node": "^24.1
|
|
38
|
-
"klubok": "0.
|
|
39
|
-
"tinybench": "^
|
|
40
|
-
"tsd": "^0.
|
|
41
|
-
"typescript": "^5.
|
|
37
|
+
"@types/node": "^24.9.1",
|
|
38
|
+
"klubok": "0.5.1",
|
|
39
|
+
"tinybench": "^5.0.1",
|
|
40
|
+
"tsd": "^0.33.0",
|
|
41
|
+
"typescript": "^5.9.3"
|
|
42
42
|
}
|
|
43
43
|
}
|