@praha/byethrow 0.7.1 → 0.7.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/dist/cjs/functions/inspect-error.cjs +4 -1
- package/dist/cjs/functions/inspect-error.d.ts +3 -3
- package/dist/cjs/functions/inspect.cjs +4 -1
- package/dist/cjs/functions/inspect.d.ts +3 -3
- package/dist/esm/functions/inspect-error.d.ts +3 -3
- package/dist/esm/functions/inspect-error.js +4 -1
- package/dist/esm/functions/inspect.d.ts +3 -3
- package/dist/esm/functions/inspect.js +4 -1
- package/package.json +4 -4
|
@@ -30,7 +30,10 @@ const external_is_failure_cjs_namespaceObject = require("./is-failure.cjs");
|
|
|
30
30
|
const is_promise_cjs_namespaceObject = require("../internals/helpers/is-promise.cjs");
|
|
31
31
|
const inspectError = (fn)=>(result)=>{
|
|
32
32
|
const apply = (r)=>{
|
|
33
|
-
if ((0, external_is_failure_cjs_namespaceObject.isFailure)(r))
|
|
33
|
+
if ((0, external_is_failure_cjs_namespaceObject.isFailure)(r)) {
|
|
34
|
+
const next = fn(r.error);
|
|
35
|
+
if ((0, is_promise_cjs_namespaceObject.isPromise)(next)) return next.then(()=>r);
|
|
36
|
+
}
|
|
34
37
|
return r;
|
|
35
38
|
};
|
|
36
39
|
return (0, is_promise_cjs_namespaceObject.isPromise)(result) ? result.then(apply) : apply(result);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InferFailure, ResultMaybeAsync } from '../result.js';
|
|
1
|
+
import type { InferFailure, InferSuccess, ResultFor, ResultMaybeAsync } from '../result.js';
|
|
2
2
|
/**
|
|
3
3
|
* Executes a side effect function on the error value of a {@link Result} or {@link ResultAsync},
|
|
4
4
|
* without modifying the original result. This is useful for debugging, logging, or performing
|
|
@@ -37,6 +37,6 @@ import type { InferFailure, ResultMaybeAsync } from '../result.js';
|
|
|
37
37
|
* @category Combinators
|
|
38
38
|
*/
|
|
39
39
|
export declare const inspectError: {
|
|
40
|
-
<R1 extends ResultMaybeAsync<any, any
|
|
41
|
-
<F extends (a: any) => unknown>(fn: F): <R1 extends ResultMaybeAsync<any, Parameters<F>[0]>>(result: R1) => R1
|
|
40
|
+
<R1 extends ResultMaybeAsync<any, any>, R2>(fn: (a: InferFailure<R1>) => R2): (result: R1) => ResultFor<R1 | R2, InferSuccess<R1>, InferFailure<R1>>;
|
|
41
|
+
<F extends (a: any) => unknown>(fn: F): <R1 extends ResultMaybeAsync<any, Parameters<F>[0]>>(result: R1) => ResultFor<R1 | ReturnType<F>, InferSuccess<R1>, InferFailure<R1>>;
|
|
42
42
|
};
|
|
@@ -30,7 +30,10 @@ const external_is_success_cjs_namespaceObject = require("./is-success.cjs");
|
|
|
30
30
|
const is_promise_cjs_namespaceObject = require("../internals/helpers/is-promise.cjs");
|
|
31
31
|
const inspect = (fn)=>(result)=>{
|
|
32
32
|
const apply = (r)=>{
|
|
33
|
-
if ((0, external_is_success_cjs_namespaceObject.isSuccess)(r))
|
|
33
|
+
if ((0, external_is_success_cjs_namespaceObject.isSuccess)(r)) {
|
|
34
|
+
const next = fn(r.value);
|
|
35
|
+
if ((0, is_promise_cjs_namespaceObject.isPromise)(next)) return next.then(()=>r);
|
|
36
|
+
}
|
|
34
37
|
return r;
|
|
35
38
|
};
|
|
36
39
|
return (0, is_promise_cjs_namespaceObject.isPromise)(result) ? result.then(apply) : apply(result);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InferSuccess, ResultMaybeAsync } from '../result.js';
|
|
1
|
+
import type { InferFailure, InferSuccess, ResultFor, ResultMaybeAsync } from '../result.js';
|
|
2
2
|
/**
|
|
3
3
|
* Executes a side effect function on the success value of a {@link Result} or {@link ResultAsync},
|
|
4
4
|
* without modifying the original result. This is useful for debugging, logging, or performing
|
|
@@ -37,6 +37,6 @@ import type { InferSuccess, ResultMaybeAsync } from '../result.js';
|
|
|
37
37
|
* @category Combinators
|
|
38
38
|
*/
|
|
39
39
|
export declare const inspect: {
|
|
40
|
-
<R1 extends ResultMaybeAsync<any, any
|
|
41
|
-
<F extends (a: any) => unknown>(fn: F): <R1 extends ResultMaybeAsync<Parameters<F>[0], any>>(result: R1) => R1
|
|
40
|
+
<R1 extends ResultMaybeAsync<any, any>, R2>(fn: (a: InferSuccess<R1>) => R2): (result: R1) => ResultFor<R1 | R2, InferSuccess<R1>, InferFailure<R1>>;
|
|
41
|
+
<F extends (a: any) => unknown>(fn: F): <R1 extends ResultMaybeAsync<Parameters<F>[0], any>>(result: R1) => ResultFor<R1 | ReturnType<F>, InferSuccess<R1>, InferFailure<R1>>;
|
|
42
42
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InferFailure, ResultMaybeAsync } from '../result.js';
|
|
1
|
+
import type { InferFailure, InferSuccess, ResultFor, ResultMaybeAsync } from '../result.js';
|
|
2
2
|
/**
|
|
3
3
|
* Executes a side effect function on the error value of a {@link Result} or {@link ResultAsync},
|
|
4
4
|
* without modifying the original result. This is useful for debugging, logging, or performing
|
|
@@ -37,6 +37,6 @@ import type { InferFailure, ResultMaybeAsync } from '../result.js';
|
|
|
37
37
|
* @category Combinators
|
|
38
38
|
*/
|
|
39
39
|
export declare const inspectError: {
|
|
40
|
-
<R1 extends ResultMaybeAsync<any, any
|
|
41
|
-
<F extends (a: any) => unknown>(fn: F): <R1 extends ResultMaybeAsync<any, Parameters<F>[0]>>(result: R1) => R1
|
|
40
|
+
<R1 extends ResultMaybeAsync<any, any>, R2>(fn: (a: InferFailure<R1>) => R2): (result: R1) => ResultFor<R1 | R2, InferSuccess<R1>, InferFailure<R1>>;
|
|
41
|
+
<F extends (a: any) => unknown>(fn: F): <R1 extends ResultMaybeAsync<any, Parameters<F>[0]>>(result: R1) => ResultFor<R1 | ReturnType<F>, InferSuccess<R1>, InferFailure<R1>>;
|
|
42
42
|
};
|
|
@@ -2,7 +2,10 @@ import { isFailure } from "./is-failure.js";
|
|
|
2
2
|
import { isPromise } from "../internals/helpers/is-promise.js";
|
|
3
3
|
const inspectError = (fn)=>(result)=>{
|
|
4
4
|
const apply = (r)=>{
|
|
5
|
-
if (isFailure(r))
|
|
5
|
+
if (isFailure(r)) {
|
|
6
|
+
const next = fn(r.error);
|
|
7
|
+
if (isPromise(next)) return next.then(()=>r);
|
|
8
|
+
}
|
|
6
9
|
return r;
|
|
7
10
|
};
|
|
8
11
|
return isPromise(result) ? result.then(apply) : apply(result);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InferSuccess, ResultMaybeAsync } from '../result.js';
|
|
1
|
+
import type { InferFailure, InferSuccess, ResultFor, ResultMaybeAsync } from '../result.js';
|
|
2
2
|
/**
|
|
3
3
|
* Executes a side effect function on the success value of a {@link Result} or {@link ResultAsync},
|
|
4
4
|
* without modifying the original result. This is useful for debugging, logging, or performing
|
|
@@ -37,6 +37,6 @@ import type { InferSuccess, ResultMaybeAsync } from '../result.js';
|
|
|
37
37
|
* @category Combinators
|
|
38
38
|
*/
|
|
39
39
|
export declare const inspect: {
|
|
40
|
-
<R1 extends ResultMaybeAsync<any, any
|
|
41
|
-
<F extends (a: any) => unknown>(fn: F): <R1 extends ResultMaybeAsync<Parameters<F>[0], any>>(result: R1) => R1
|
|
40
|
+
<R1 extends ResultMaybeAsync<any, any>, R2>(fn: (a: InferSuccess<R1>) => R2): (result: R1) => ResultFor<R1 | R2, InferSuccess<R1>, InferFailure<R1>>;
|
|
41
|
+
<F extends (a: any) => unknown>(fn: F): <R1 extends ResultMaybeAsync<Parameters<F>[0], any>>(result: R1) => ResultFor<R1 | ReturnType<F>, InferSuccess<R1>, InferFailure<R1>>;
|
|
42
42
|
};
|
|
@@ -2,7 +2,10 @@ import { isSuccess } from "./is-success.js";
|
|
|
2
2
|
import { isPromise } from "../internals/helpers/is-promise.js";
|
|
3
3
|
const inspect = (fn)=>(result)=>{
|
|
4
4
|
const apply = (r)=>{
|
|
5
|
-
if (isSuccess(r))
|
|
5
|
+
if (isSuccess(r)) {
|
|
6
|
+
const next = fn(r.value);
|
|
7
|
+
if (isPromise(next)) return next.then(()=>r);
|
|
8
|
+
}
|
|
6
9
|
return r;
|
|
7
10
|
};
|
|
8
11
|
return isPromise(result) ? result.then(apply) : apply(result);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@praha/byethrow",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "A lightweight, tree-shakable Result type package with a simple, consistent API designed",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"@standard-schema/spec": "^1.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@rslib/core": "0.
|
|
48
|
-
"eslint": "9.
|
|
47
|
+
"@rslib/core": "0.15.0",
|
|
48
|
+
"eslint": "9.37.0",
|
|
49
49
|
"typedoc": "0.28.13",
|
|
50
50
|
"typedoc-plugin-markdown": "4.9.0",
|
|
51
|
-
"typescript": "5.9.
|
|
51
|
+
"typescript": "5.9.3",
|
|
52
52
|
"vitest": "3.2.4"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|