mini-effect 0.0.2 → 0.0.4
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/fetch.d.mts +8 -7
- package/dist/mini-effect.d.mts +2 -2
- package/dist/schema.d.mts +3 -1
- package/package.json +1 -1
package/dist/fetch.d.mts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Effect } from "./mini-effect.mjs";
|
|
2
|
-
import { FailureConstructor } from "./tag.mjs";
|
|
2
|
+
import { Failure, FailureConstructor } from "./tag.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/fetch.d.ts
|
|
5
|
+
declare const FailedToFetchError: FailureConstructor<"FailedToFetch">;
|
|
5
6
|
declare const FailedToReadError: FailureConstructor<"FailedToRead">;
|
|
6
|
-
declare const request: (input: string | URL, init?: RequestInit) => Effect<Response,
|
|
7
|
-
declare const blob: (response: Response) => Effect<
|
|
8
|
-
declare const bytes: (response: Response) => Effect<
|
|
9
|
-
declare const formData: (response: Response) => Effect<
|
|
10
|
-
declare const json: (response: Response) => Effect<unknown, typeof FailedToReadError
|
|
11
|
-
declare const text: (response: Response) => Effect<
|
|
7
|
+
declare const request: (input: string | URL, init?: RequestInit) => Effect<Response, InstanceType<typeof FailedToFetchError>>;
|
|
8
|
+
declare const blob: (response: Response) => Effect<Blob, Failure<"FailedToRead">>;
|
|
9
|
+
declare const bytes: (response: Response) => Effect<Uint8Array<ArrayBuffer>, Failure<"FailedToRead">>;
|
|
10
|
+
declare const formData: (response: Response) => Effect<FormData, Failure<"FailedToRead">>;
|
|
11
|
+
declare const json: (response: Response) => Effect<unknown, InstanceType<typeof FailedToReadError>>;
|
|
12
|
+
declare const text: (response: Response) => Effect<string, Failure<"FailedToRead">>;
|
|
12
13
|
//#endregion
|
|
13
14
|
export { blob, bytes, formData, json, request, text };
|
package/dist/mini-effect.d.mts
CHANGED
|
@@ -31,8 +31,8 @@ type inferInput<T> = T extends PipeableThunk<any, any, infer I> ? I : never;
|
|
|
31
31
|
type inferReturn<T> = T extends WrapEffect<infer R> ? R : T extends Effect<infer R> ? R : T extends PipeableThunk<infer R> ? R : never;
|
|
32
32
|
type inferError<T> = T extends PipeableThunk<any, infer E> ? E : T extends WrapEffect<any, infer E> ? E : T extends Effect<any, infer E> ? E : never;
|
|
33
33
|
type inferExclude<T> = T extends WrapEffect<any, any, infer CE> ? CE : never;
|
|
34
|
-
type Simplify<T> = T extends Effect<infer R, infer E> ? Effect<R, E> :
|
|
35
|
-
type PipeReturn<F extends Pipeable[]> = IsNever<CheckPipe<F>> extends true ? never : Simplify<Effect<inferReturn<CheckPipe<F>> | inferReturn<Extract<F[number], WrapEffect
|
|
34
|
+
type Simplify<T> = T extends Effect<infer R, infer E> ? Effect<R, E> : never;
|
|
35
|
+
type PipeReturn<F extends Pipeable[]> = IsNever<CheckPipe<F>> extends true ? never : Simplify<Effect<inferReturn<CheckPipe<F>> | inferReturn<Extract<F[number], WrapEffect>>, Exclude<inferError<F[number]>, inferExclude<Extract<F[number], WrapEffect>>>>>;
|
|
36
36
|
type CheckPipe<F extends Pipeable[]> = F extends [Effect, WrapEffect, ...infer R] ? R extends [Pipeable, ...Pipeable[]] ? CheckPipe<R> : F[0] : F extends [Pipeable, Pipeable, ...infer P] ? ExtendsStrict<inferReturn<F[0]>, inferInput<F[1]>> extends true ? P extends Pipeable[] ? CheckPipe<[F[1], ...P]> : never : never : F extends [WrapEffect] ? Effect<inferReturn<F[0]>> : F extends [Pipeable] ? F[0] : never;
|
|
37
37
|
type IsNever<T> = [T] extends [never] ? true : false;
|
|
38
38
|
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
package/dist/schema.d.mts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Effect } from "./mini-effect.mjs";
|
|
2
|
+
import { FailureConstructor } from "./tag.mjs";
|
|
2
3
|
import * as v from "valibot";
|
|
3
4
|
export * from "valibot";
|
|
4
5
|
|
|
5
6
|
//#region src/schema.d.ts
|
|
6
7
|
type Schema = v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>> | v.BaseSchemaAsync<unknown, unknown, v.BaseIssue<unknown>>;
|
|
7
|
-
declare const
|
|
8
|
+
declare const FaildToValidateError: FailureConstructor<"FailedToValidate">;
|
|
9
|
+
declare const validate: <const S extends Schema>(schema: S) => (value: unknown) => Effect<v.InferOutput<S>, InstanceType<typeof FaildToValidateError>>;
|
|
8
10
|
//#endregion
|
|
9
11
|
export { Schema, validate };
|