@zokugun/xtry 0.10.1 → 0.11.0
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/lib/cjs/async.d.cts +2 -2
- package/lib/cjs/index.d.cts +2 -2
- package/lib/cjs/json.d.cts +2 -2
- package/lib/cjs/result.d.cts +3 -0
- package/lib/cjs/sync.d.cts +2 -2
- package/lib/cjs/tryify.d.cts +8 -8
- package/lib/esm/async.d.mts +2 -2
- package/lib/esm/index.d.mts +2 -2
- package/lib/esm/json.d.mts +2 -2
- package/lib/esm/result.d.mts +3 -0
- package/lib/esm/sync.d.mts +2 -2
- package/lib/esm/tryify.d.mts +8 -8
- package/package.json +15 -6
package/lib/cjs/async.d.cts
CHANGED
|
@@ -3,10 +3,10 @@ export { xdefer as xdeferUnknown, xdeferAsync as xdefer, xdeferSync } from './de
|
|
|
3
3
|
export { parseJSON, parseJson } from './json.cjs';
|
|
4
4
|
export type { YResult, YSuccess, YFailure } from './partial.cjs';
|
|
5
5
|
export { yok, yerr, yres as yresUnknown, yresAsync as yres, yresSync, yep, YOK, YOK_FALSE, YOK_NULL, YOK_TRUE, YOK_UNDEFINED } from './partial.cjs';
|
|
6
|
-
export type { Success, Failure, Result } from './result.cjs';
|
|
6
|
+
export type { Success, Failure, Result, AsyncResult, DResult, AsyncDResult } from './result.cjs';
|
|
7
7
|
export { ok, err, OK, OK_FALSE, OK_NULL, OK_TRUE, OK_UNDEFINED } from './result.cjs';
|
|
8
8
|
export { stringifyError } from './stringify-error.cjs';
|
|
9
9
|
export { toStringFailure } from './to-string-failure.cjs';
|
|
10
10
|
export { xtry as xtryUnknown, xtryAsync as xtry, xtryAsyncIterable as xtryIterable, xtrySync, xtrySyncIterable } from './try.cjs';
|
|
11
|
-
export type { AsyncFunction, AsyncIterableFunction,
|
|
11
|
+
export type { AsyncFunction, AsyncIterableFunction, AsyncIteratableFunctionResult, AsyncIteratorElement, AsyncFunctionResult, PreserveAsyncIterableOverloads, PreserveAsyncOverloads, PreserveSyncIterableOverloads, PreserveSyncOverloads, SyncFunction, SyncIterableFunction, SyncIteratableFunctionResult, SyncIteratorElement, SyncFunctionResult } from './tryify.cjs';
|
|
12
12
|
export { xtryifyAsync as xtryify, xtryifyAsyncIterable as xtryifyIterable, xtryifySync, xtryifySyncIterable } from './tryify.cjs';
|
package/lib/cjs/index.d.cts
CHANGED
|
@@ -3,10 +3,10 @@ export { xdefer, xdeferAsync, xdeferSync } from './defer.cjs';
|
|
|
3
3
|
export { parseJSON, parseJson } from './json.cjs';
|
|
4
4
|
export type { YResult, YSuccess, YFailure } from './partial.cjs';
|
|
5
5
|
export { yok, yerr, yres, yresAsync, yresSync, yep, YOK, YOK_NULL, YOK_TRUE, YOK_FALSE, YOK_UNDEFINED } from './partial.cjs';
|
|
6
|
-
export type { Success, Failure, Result } from './result.cjs';
|
|
6
|
+
export type { Success, Failure, Result, AsyncResult, DResult, AsyncDResult } from './result.cjs';
|
|
7
7
|
export { ok, err, OK, OK_FALSE, OK_NULL, OK_TRUE, OK_UNDEFINED } from './result.cjs';
|
|
8
8
|
export { stringifyError } from './stringify-error.cjs';
|
|
9
9
|
export { toStringFailure } from './to-string-failure.cjs';
|
|
10
10
|
export { xtry, xtryAsync, xtryAsyncIterable, xtrySync, xtrySyncIterable } from './try.cjs';
|
|
11
|
-
export type { AsyncFunction, AsyncIterableFunction,
|
|
11
|
+
export type { AsyncFunction, AsyncIterableFunction, AsyncIteratableFunctionResult, AsyncIteratorElement, AsyncFunctionResult, PreserveAsyncIterableOverloads, PreserveAsyncOverloads, PreserveSyncIterableOverloads, PreserveSyncOverloads, SyncFunction, SyncIterableFunction, SyncIteratableFunctionResult, SyncIteratorElement, SyncFunctionResult } from './tryify.cjs';
|
|
12
12
|
export { xtryifyAsync, xtryifyAsyncIterable, xtryifySync, xtryifySyncIterable } from './tryify.cjs';
|
package/lib/cjs/json.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const parseJson: (...args: unknown[]) => import("./tryify.cjs").
|
|
2
|
-
export declare const parseJSON: (...args: unknown[]) => import("./tryify.cjs").
|
|
1
|
+
export declare const parseJson: (...args: unknown[]) => import("./tryify.cjs").SyncFunctionResult<any, SyntaxError>;
|
|
2
|
+
export declare const parseJSON: (...args: unknown[]) => import("./tryify.cjs").SyncFunctionResult<any, SyntaxError>;
|
package/lib/cjs/result.d.cts
CHANGED
|
@@ -9,6 +9,9 @@ export type Failure<E> = {
|
|
|
9
9
|
error: E;
|
|
10
10
|
};
|
|
11
11
|
export type Result<T, E> = Success<T> | Failure<E>;
|
|
12
|
+
export type AsyncResult<T, E> = Promise<Result<T, E>>;
|
|
13
|
+
export type DResult<T = void, E = string> = Result<T, E>;
|
|
14
|
+
export type AsyncDResult<T = void, E = string> = AsyncResult<T, E>;
|
|
12
15
|
export declare function ok(): Success<void>;
|
|
13
16
|
export declare function ok<T>(value: T): Success<T>;
|
|
14
17
|
export declare function err<E>(error: E): Failure<E>;
|
package/lib/cjs/sync.d.cts
CHANGED
|
@@ -3,10 +3,10 @@ export { xdefer as xdeferUnknown, xdeferAsync, xdeferSync as xdefer } from './de
|
|
|
3
3
|
export { parseJSON, parseJson } from './json.cjs';
|
|
4
4
|
export type { YResult, YSuccess, YFailure } from './partial.cjs';
|
|
5
5
|
export { yok, yerr, yres as yresUnknown, yresAsync, yresSync as yres, yep, YOK, YOK_FALSE, YOK_NULL, YOK_TRUE, YOK_UNDEFINED } from './partial.cjs';
|
|
6
|
-
export type { Success, Failure, Result } from './result.cjs';
|
|
6
|
+
export type { Success, Failure, Result, AsyncResult, DResult, AsyncDResult } from './result.cjs';
|
|
7
7
|
export { ok, err, OK, OK_FALSE, OK_NULL, OK_TRUE, OK_UNDEFINED } from './result.cjs';
|
|
8
8
|
export { stringifyError } from './stringify-error.cjs';
|
|
9
9
|
export { toStringFailure } from './to-string-failure.cjs';
|
|
10
10
|
export { xtry as xtryUnknown, xtryAsync, xtryAsyncIterable, xtrySync as xtry, xtrySyncIterable as xtryIterable } from './try.cjs';
|
|
11
|
-
export type { AsyncFunction, AsyncIterableFunction,
|
|
11
|
+
export type { AsyncFunction, AsyncIterableFunction, AsyncIteratableFunctionResult, AsyncIteratorElement, AsyncFunctionResult, PreserveAsyncIterableOverloads, PreserveAsyncOverloads, PreserveSyncIterableOverloads, PreserveSyncOverloads, SyncFunction, SyncIterableFunction, SyncIteratableFunctionResult, SyncIteratorElement, SyncFunctionResult } from './tryify.cjs';
|
|
12
12
|
export { xtryifyAsync, xtryifyAsyncIterable, xtryifySync as xtryify, xtryifySyncIterable as xtryifyIterable } from './tryify.cjs';
|
package/lib/cjs/tryify.d.cts
CHANGED
|
@@ -16,17 +16,17 @@ type OverloadsUnion<Fn extends Function> = Fn extends {
|
|
|
16
16
|
(...args: infer A10): infer R10;
|
|
17
17
|
} ? ((...args: A1) => R1) | ((...args: A2) => R2) | ((...args: A3) => R3) | ((...args: A4) => R4) | ((...args: A5) => R5) | ((...args: A6) => R6) | ((...args: A7) => R7) | ((...args: A8) => R8) | ((...args: A9) => R9) | ((...args: A10) => R10) : Fn;
|
|
18
18
|
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
19
|
-
type WrapAsyncOverload<Fn extends AnyAsyncFunction, Err extends Error> = Fn extends (...args: infer Args) => unknown ? (...args: Args) =>
|
|
20
|
-
type WrapAsyncIterableOverload<Fn extends AsyncIterableFunction, Err extends Error> = Fn extends (...args: infer Args) => AsyncIterable<unknown> ? (...args: Args) =>
|
|
21
|
-
type WrapSyncOverload<Fn extends AnySyncFunction, Err extends Error> = Fn extends (...args: infer Args) => unknown ? (...args: Args) =>
|
|
22
|
-
type WrapSyncIterableOverload<Fn extends SyncIterableFunction, Err extends Error> = Fn extends (...args: infer Args) => Iterable<unknown> ? (...args: Args) =>
|
|
19
|
+
type WrapAsyncOverload<Fn extends AnyAsyncFunction, Err extends Error> = Fn extends (...args: infer Args) => unknown ? (...args: Args) => AsyncFunctionResult<Fn, Err> : never;
|
|
20
|
+
type WrapAsyncIterableOverload<Fn extends AsyncIterableFunction, Err extends Error> = Fn extends (...args: infer Args) => AsyncIterable<unknown> ? (...args: Args) => AsyncIteratableFunctionResult<Fn, Err> : never;
|
|
21
|
+
type WrapSyncOverload<Fn extends AnySyncFunction, Err extends Error> = Fn extends (...args: infer Args) => unknown ? (...args: Args) => SyncFunctionResult<Fn, Err> : never;
|
|
22
|
+
type WrapSyncIterableOverload<Fn extends SyncIterableFunction, Err extends Error> = Fn extends (...args: infer Args) => Iterable<unknown> ? (...args: Args) => SyncIteratableFunctionResult<Fn, Err> : never;
|
|
23
23
|
export type AsyncFunction<Fn extends (...args: any[]) => any> = ReturnType<Fn> extends Promise<any> ? Fn : never;
|
|
24
24
|
export type AsyncIterableFunction = (...args: any[]) => AsyncIterable<unknown>;
|
|
25
25
|
export type AsyncIteratorElement<T> = T extends Promise<infer P> ? AsyncIteratorElement<P> : T extends AsyncIterator<infer E> ? E : T extends AsyncIterable<infer E> ? E : T extends {
|
|
26
26
|
[Symbol.asyncIterator]: (...args: unknown[]) => infer I;
|
|
27
27
|
} ? AsyncIteratorElement<I> : unknown;
|
|
28
|
-
export type
|
|
29
|
-
export type
|
|
28
|
+
export type AsyncFunctionResult<T extends (...args: unknown[]) => unknown, Err extends Error> = Promise<Result<Awaited<ReturnType<T>>, Err>>;
|
|
29
|
+
export type AsyncIteratableFunctionResult<T extends (...args: unknown[]) => unknown, Err extends Error> = AsyncIterable<Result<AsyncIteratorElement<ReturnType<T>>, Err>, unknown, unknown>;
|
|
30
30
|
export type PreserveAsyncOverloads<Fn extends AnyAsyncFunction, Err extends Error> = UnionToIntersection<WrapAsyncOverload<OverloadsUnion<Fn>, Err>>;
|
|
31
31
|
export type PreserveAsyncIterableOverloads<Fn extends AsyncIterableFunction, Err extends Error> = UnionToIntersection<WrapAsyncIterableOverload<OverloadsUnion<Fn>, Err>>;
|
|
32
32
|
export type PreserveSyncOverloads<Fn extends AnySyncFunction, Err extends Error> = UnionToIntersection<WrapSyncOverload<OverloadsUnion<Fn>, Err>>;
|
|
@@ -36,8 +36,8 @@ export type SyncIterableFunction = (...args: any[]) => Iterable<unknown>;
|
|
|
36
36
|
export type SyncIteratorElement<T> = T extends Iterator<infer E> ? E : T extends Iterable<infer E> ? E : T extends {
|
|
37
37
|
[Symbol.iterator]: (...args: unknown[]) => infer I;
|
|
38
38
|
} ? SyncIteratorElement<I> : unknown;
|
|
39
|
-
export type
|
|
40
|
-
export type
|
|
39
|
+
export type SyncFunctionResult<T extends (...args: unknown[]) => NotPromise<unknown>, Err extends Error> = Result<ReturnType<T>, Err>;
|
|
40
|
+
export type SyncIteratableFunctionResult<T extends (...args: unknown[]) => unknown, Err extends Error> = Iterable<Result<SyncIteratorElement<ReturnType<T>>, Err>, unknown, unknown>;
|
|
41
41
|
export declare function xtryifyAsync<Err extends Error, Fn extends AnyAsyncFunction = any>(fn: AsyncFunction<Fn>): PreserveAsyncOverloads<Fn, Err>;
|
|
42
42
|
export declare function xtryifyAsyncIterable<Err extends Error, Fn extends AsyncIterableFunction = any>(fn: Fn): PreserveAsyncIterableOverloads<Fn, Err>;
|
|
43
43
|
export declare function xtryifySync<Err extends Error, Fn extends AnySyncFunction = any>(fn: SyncFunction<Fn>): PreserveSyncOverloads<Fn, Err>;
|
package/lib/esm/async.d.mts
CHANGED
|
@@ -3,10 +3,10 @@ export { xdefer as xdeferUnknown, xdeferAsync as xdefer, xdeferSync } from './de
|
|
|
3
3
|
export { parseJSON, parseJson } from './json.mjs';
|
|
4
4
|
export type { YResult, YSuccess, YFailure } from './partial.mjs';
|
|
5
5
|
export { yok, yerr, yres as yresUnknown, yresAsync as yres, yresSync, yep, YOK, YOK_FALSE, YOK_NULL, YOK_TRUE, YOK_UNDEFINED } from './partial.mjs';
|
|
6
|
-
export type { Success, Failure, Result } from './result.mjs';
|
|
6
|
+
export type { Success, Failure, Result, AsyncResult, DResult, AsyncDResult } from './result.mjs';
|
|
7
7
|
export { ok, err, OK, OK_FALSE, OK_NULL, OK_TRUE, OK_UNDEFINED } from './result.mjs';
|
|
8
8
|
export { stringifyError } from './stringify-error.mjs';
|
|
9
9
|
export { toStringFailure } from './to-string-failure.mjs';
|
|
10
10
|
export { xtry as xtryUnknown, xtryAsync as xtry, xtryAsyncIterable as xtryIterable, xtrySync, xtrySyncIterable } from './try.mjs';
|
|
11
|
-
export type { AsyncFunction, AsyncIterableFunction,
|
|
11
|
+
export type { AsyncFunction, AsyncIterableFunction, AsyncIteratableFunctionResult, AsyncIteratorElement, AsyncFunctionResult, PreserveAsyncIterableOverloads, PreserveAsyncOverloads, PreserveSyncIterableOverloads, PreserveSyncOverloads, SyncFunction, SyncIterableFunction, SyncIteratableFunctionResult, SyncIteratorElement, SyncFunctionResult } from './tryify.mjs';
|
|
12
12
|
export { xtryifyAsync as xtryify, xtryifyAsyncIterable as xtryifyIterable, xtryifySync, xtryifySyncIterable } from './tryify.mjs';
|
package/lib/esm/index.d.mts
CHANGED
|
@@ -3,10 +3,10 @@ export { xdefer, xdeferAsync, xdeferSync } from './defer.mjs';
|
|
|
3
3
|
export { parseJSON, parseJson } from './json.mjs';
|
|
4
4
|
export type { YResult, YSuccess, YFailure } from './partial.mjs';
|
|
5
5
|
export { yok, yerr, yres, yresAsync, yresSync, yep, YOK, YOK_NULL, YOK_TRUE, YOK_FALSE, YOK_UNDEFINED } from './partial.mjs';
|
|
6
|
-
export type { Success, Failure, Result } from './result.mjs';
|
|
6
|
+
export type { Success, Failure, Result, AsyncResult, DResult, AsyncDResult } from './result.mjs';
|
|
7
7
|
export { ok, err, OK, OK_FALSE, OK_NULL, OK_TRUE, OK_UNDEFINED } from './result.mjs';
|
|
8
8
|
export { stringifyError } from './stringify-error.mjs';
|
|
9
9
|
export { toStringFailure } from './to-string-failure.mjs';
|
|
10
10
|
export { xtry, xtryAsync, xtryAsyncIterable, xtrySync, xtrySyncIterable } from './try.mjs';
|
|
11
|
-
export type { AsyncFunction, AsyncIterableFunction,
|
|
11
|
+
export type { AsyncFunction, AsyncIterableFunction, AsyncIteratableFunctionResult, AsyncIteratorElement, AsyncFunctionResult, PreserveAsyncIterableOverloads, PreserveAsyncOverloads, PreserveSyncIterableOverloads, PreserveSyncOverloads, SyncFunction, SyncIterableFunction, SyncIteratableFunctionResult, SyncIteratorElement, SyncFunctionResult } from './tryify.mjs';
|
|
12
12
|
export { xtryifyAsync, xtryifyAsyncIterable, xtryifySync, xtryifySyncIterable } from './tryify.mjs';
|
package/lib/esm/json.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const parseJson: (...args: unknown[]) => import("./tryify.mjs").
|
|
2
|
-
export declare const parseJSON: (...args: unknown[]) => import("./tryify.mjs").
|
|
1
|
+
export declare const parseJson: (...args: unknown[]) => import("./tryify.mjs").SyncFunctionResult<any, SyntaxError>;
|
|
2
|
+
export declare const parseJSON: (...args: unknown[]) => import("./tryify.mjs").SyncFunctionResult<any, SyntaxError>;
|
package/lib/esm/result.d.mts
CHANGED
|
@@ -9,6 +9,9 @@ export type Failure<E> = {
|
|
|
9
9
|
error: E;
|
|
10
10
|
};
|
|
11
11
|
export type Result<T, E> = Success<T> | Failure<E>;
|
|
12
|
+
export type AsyncResult<T, E> = Promise<Result<T, E>>;
|
|
13
|
+
export type DResult<T = void, E = string> = Result<T, E>;
|
|
14
|
+
export type AsyncDResult<T = void, E = string> = AsyncResult<T, E>;
|
|
12
15
|
export declare function ok(): Success<void>;
|
|
13
16
|
export declare function ok<T>(value: T): Success<T>;
|
|
14
17
|
export declare function err<E>(error: E): Failure<E>;
|
package/lib/esm/sync.d.mts
CHANGED
|
@@ -3,10 +3,10 @@ export { xdefer as xdeferUnknown, xdeferAsync, xdeferSync as xdefer } from './de
|
|
|
3
3
|
export { parseJSON, parseJson } from './json.mjs';
|
|
4
4
|
export type { YResult, YSuccess, YFailure } from './partial.mjs';
|
|
5
5
|
export { yok, yerr, yres as yresUnknown, yresAsync, yresSync as yres, yep, YOK, YOK_FALSE, YOK_NULL, YOK_TRUE, YOK_UNDEFINED } from './partial.mjs';
|
|
6
|
-
export type { Success, Failure, Result } from './result.mjs';
|
|
6
|
+
export type { Success, Failure, Result, AsyncResult, DResult, AsyncDResult } from './result.mjs';
|
|
7
7
|
export { ok, err, OK, OK_FALSE, OK_NULL, OK_TRUE, OK_UNDEFINED } from './result.mjs';
|
|
8
8
|
export { stringifyError } from './stringify-error.mjs';
|
|
9
9
|
export { toStringFailure } from './to-string-failure.mjs';
|
|
10
10
|
export { xtry as xtryUnknown, xtryAsync, xtryAsyncIterable, xtrySync as xtry, xtrySyncIterable as xtryIterable } from './try.mjs';
|
|
11
|
-
export type { AsyncFunction, AsyncIterableFunction,
|
|
11
|
+
export type { AsyncFunction, AsyncIterableFunction, AsyncIteratableFunctionResult, AsyncIteratorElement, AsyncFunctionResult, PreserveAsyncIterableOverloads, PreserveAsyncOverloads, PreserveSyncIterableOverloads, PreserveSyncOverloads, SyncFunction, SyncIterableFunction, SyncIteratableFunctionResult, SyncIteratorElement, SyncFunctionResult } from './tryify.mjs';
|
|
12
12
|
export { xtryifyAsync, xtryifyAsyncIterable, xtryifySync as xtryify, xtryifySyncIterable as xtryifyIterable } from './tryify.mjs';
|
package/lib/esm/tryify.d.mts
CHANGED
|
@@ -16,17 +16,17 @@ type OverloadsUnion<Fn extends Function> = Fn extends {
|
|
|
16
16
|
(...args: infer A10): infer R10;
|
|
17
17
|
} ? ((...args: A1) => R1) | ((...args: A2) => R2) | ((...args: A3) => R3) | ((...args: A4) => R4) | ((...args: A5) => R5) | ((...args: A6) => R6) | ((...args: A7) => R7) | ((...args: A8) => R8) | ((...args: A9) => R9) | ((...args: A10) => R10) : Fn;
|
|
18
18
|
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
19
|
-
type WrapAsyncOverload<Fn extends AnyAsyncFunction, Err extends Error> = Fn extends (...args: infer Args) => unknown ? (...args: Args) =>
|
|
20
|
-
type WrapAsyncIterableOverload<Fn extends AsyncIterableFunction, Err extends Error> = Fn extends (...args: infer Args) => AsyncIterable<unknown> ? (...args: Args) =>
|
|
21
|
-
type WrapSyncOverload<Fn extends AnySyncFunction, Err extends Error> = Fn extends (...args: infer Args) => unknown ? (...args: Args) =>
|
|
22
|
-
type WrapSyncIterableOverload<Fn extends SyncIterableFunction, Err extends Error> = Fn extends (...args: infer Args) => Iterable<unknown> ? (...args: Args) =>
|
|
19
|
+
type WrapAsyncOverload<Fn extends AnyAsyncFunction, Err extends Error> = Fn extends (...args: infer Args) => unknown ? (...args: Args) => AsyncFunctionResult<Fn, Err> : never;
|
|
20
|
+
type WrapAsyncIterableOverload<Fn extends AsyncIterableFunction, Err extends Error> = Fn extends (...args: infer Args) => AsyncIterable<unknown> ? (...args: Args) => AsyncIteratableFunctionResult<Fn, Err> : never;
|
|
21
|
+
type WrapSyncOverload<Fn extends AnySyncFunction, Err extends Error> = Fn extends (...args: infer Args) => unknown ? (...args: Args) => SyncFunctionResult<Fn, Err> : never;
|
|
22
|
+
type WrapSyncIterableOverload<Fn extends SyncIterableFunction, Err extends Error> = Fn extends (...args: infer Args) => Iterable<unknown> ? (...args: Args) => SyncIteratableFunctionResult<Fn, Err> : never;
|
|
23
23
|
export type AsyncFunction<Fn extends (...args: any[]) => any> = ReturnType<Fn> extends Promise<any> ? Fn : never;
|
|
24
24
|
export type AsyncIterableFunction = (...args: any[]) => AsyncIterable<unknown>;
|
|
25
25
|
export type AsyncIteratorElement<T> = T extends Promise<infer P> ? AsyncIteratorElement<P> : T extends AsyncIterator<infer E> ? E : T extends AsyncIterable<infer E> ? E : T extends {
|
|
26
26
|
[Symbol.asyncIterator]: (...args: unknown[]) => infer I;
|
|
27
27
|
} ? AsyncIteratorElement<I> : unknown;
|
|
28
|
-
export type
|
|
29
|
-
export type
|
|
28
|
+
export type AsyncFunctionResult<T extends (...args: unknown[]) => unknown, Err extends Error> = Promise<Result<Awaited<ReturnType<T>>, Err>>;
|
|
29
|
+
export type AsyncIteratableFunctionResult<T extends (...args: unknown[]) => unknown, Err extends Error> = AsyncIterable<Result<AsyncIteratorElement<ReturnType<T>>, Err>, unknown, unknown>;
|
|
30
30
|
export type PreserveAsyncOverloads<Fn extends AnyAsyncFunction, Err extends Error> = UnionToIntersection<WrapAsyncOverload<OverloadsUnion<Fn>, Err>>;
|
|
31
31
|
export type PreserveAsyncIterableOverloads<Fn extends AsyncIterableFunction, Err extends Error> = UnionToIntersection<WrapAsyncIterableOverload<OverloadsUnion<Fn>, Err>>;
|
|
32
32
|
export type PreserveSyncOverloads<Fn extends AnySyncFunction, Err extends Error> = UnionToIntersection<WrapSyncOverload<OverloadsUnion<Fn>, Err>>;
|
|
@@ -36,8 +36,8 @@ export type SyncIterableFunction = (...args: any[]) => Iterable<unknown>;
|
|
|
36
36
|
export type SyncIteratorElement<T> = T extends Iterator<infer E> ? E : T extends Iterable<infer E> ? E : T extends {
|
|
37
37
|
[Symbol.iterator]: (...args: unknown[]) => infer I;
|
|
38
38
|
} ? SyncIteratorElement<I> : unknown;
|
|
39
|
-
export type
|
|
40
|
-
export type
|
|
39
|
+
export type SyncFunctionResult<T extends (...args: unknown[]) => NotPromise<unknown>, Err extends Error> = Result<ReturnType<T>, Err>;
|
|
40
|
+
export type SyncIteratableFunctionResult<T extends (...args: unknown[]) => unknown, Err extends Error> = Iterable<Result<SyncIteratorElement<ReturnType<T>>, Err>, unknown, unknown>;
|
|
41
41
|
export declare function xtryifyAsync<Err extends Error, Fn extends AnyAsyncFunction = any>(fn: AsyncFunction<Fn>): PreserveAsyncOverloads<Fn, Err>;
|
|
42
42
|
export declare function xtryifyAsyncIterable<Err extends Error, Fn extends AsyncIterableFunction = any>(fn: Fn): PreserveAsyncIterableOverloads<Fn, Err>;
|
|
43
43
|
export declare function xtryifySync<Err extends Error, Fn extends AnySyncFunction = any>(fn: SyncFunction<Fn>): PreserveSyncOverloads<Fn, Err>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zokugun/xtry",
|
|
3
3
|
"description": "simple try/catch wrapper returning Result",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.11.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Baptiste Augrain",
|
|
7
7
|
"email": "daiyam@zokugun.org"
|
|
@@ -64,7 +64,6 @@
|
|
|
64
64
|
"build:lib": "tsc-leda generate",
|
|
65
65
|
"build:package": "tsc-leda update-package",
|
|
66
66
|
"clean": "rimraf lib .test",
|
|
67
|
-
"commit": "cz",
|
|
68
67
|
"compile:src": "tsc -p src",
|
|
69
68
|
"compile:test": "tsc -p test",
|
|
70
69
|
"lint": "xo",
|
|
@@ -72,7 +71,9 @@
|
|
|
72
71
|
"prepack": "npm run build",
|
|
73
72
|
"prepare": "husky; fixpack || true",
|
|
74
73
|
"release": "release-it",
|
|
75
|
-
"test": "vitest run",
|
|
74
|
+
"test": "vitest run --reporter tree",
|
|
75
|
+
"test:coverage": "vitest run --reporter tree --coverage --coverage.reporter text",
|
|
76
|
+
"test:ui": "vitest --ui --coverage",
|
|
76
77
|
"test:watch": "vitest",
|
|
77
78
|
"watch:src": "tsc-watch -p src",
|
|
78
79
|
"watch:test": "tsc-watch -p test"
|
|
@@ -83,18 +84,26 @@
|
|
|
83
84
|
"@commitlint/config-conventional": "^19.7.1",
|
|
84
85
|
"@types/fs-extra": "^11.0.4",
|
|
85
86
|
"@types/node": "^20.14.8",
|
|
87
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
88
|
+
"@vitest/ui": "^4.0.18",
|
|
89
|
+
"@zokugun/fs-extra-plus": "^0.3.3",
|
|
86
90
|
"@zokugun/tsc-leda": "^0.1.1",
|
|
87
91
|
"fixpack": "^4.0.0",
|
|
88
92
|
"fs-extra": "^11.3.3",
|
|
89
|
-
"globby": "^16.1.
|
|
93
|
+
"globby": "^16.1.1",
|
|
90
94
|
"husky": "^9.1.7",
|
|
91
95
|
"lint-staged": "^16.1.4",
|
|
92
96
|
"release-it": "^19.2.4",
|
|
93
|
-
"tsc-watch": "^
|
|
97
|
+
"tsc-watch": "^7.2.0",
|
|
94
98
|
"typescript": "^5.7.3",
|
|
95
|
-
"vitest": "^4.0.
|
|
99
|
+
"vitest": "^4.0.18",
|
|
96
100
|
"xo": "0.60.0"
|
|
97
101
|
},
|
|
102
|
+
"overrides": {
|
|
103
|
+
"terser-webpack-plugin": {
|
|
104
|
+
"serialize-javascript": "^7.0.3"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
98
107
|
"keywords": [
|
|
99
108
|
"catch",
|
|
100
109
|
"error",
|