🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@effect/match

Package Overview
Dependencies
Maintainers
3
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effect/match - npm Package Compare versions

Comparing version

to
0.19.0

28

index.d.ts

@@ -71,7 +71,3 @@ /**

*/
export declare const when: {
<R, P extends PatternBase<R>, B>(pattern: Narrow<P>, f: (_: WhenMatch<R, P>) => B): <I, F, A, Pr>(self: Matcher<I, F, R, A, Pr>) => Matcher<I, AddWithout<F, PForExclude<P>>, ApplyFilters<I, AddWithout<F, PForExclude<P>>>, A | B, Pr>;
<R, P extends PredicateA<R>, B>(pattern: P, f: (_: WhenMatch<R, P>) => B): <I, F, A, Pr>(self: Matcher<I, F, R, A, Pr>) => Matcher<I, AddWithout<F, PForExclude<P>>, ApplyFilters<I, AddWithout<F, PForExclude<P>>>, A | B, Pr>;
<P, SR, R, B>(schema: SafeSchema<P, SR>, f: (_: WhenSchemaMatch<R, P>) => B): <I, F, A, Pr>(self: Matcher<I, F, R, A, Pr>) => Matcher<I, AddWithout<F, WhenSchemaMatch<R, P>>, ApplyFilters<I, AddWithout<F, WhenSchemaMatch<R, P>>>, A | B, Pr>;
};
export declare const when: <R, const P extends PatternPrimitive<R> | PatternBase<R>, B>(pattern: P, f: (_: ExtractMatch<R, RemoveInvalidPatterns<SafeSchemaP<ResolvePred<P>>>>) => B) => <I, F, A, Pr>(self: Matcher<I, F, R, A, Pr>) => Matcher<I, AddWithout<F, RemoveInvalidPatterns<SafeSchemaR<PredToSchema<P>>>>, ApplyFilters<I, AddWithout<F, RemoveInvalidPatterns<SafeSchemaR<PredToSchema<P>>>>>, B | A, Pr>;
/**

@@ -95,7 +91,3 @@ * @category combinators

*/
export declare const not: {
<R, P extends PatternBase<R>, B>(pattern: Narrow<P>, f: (_: NotMatch<R, P>) => B): <I, F, A, Pr>(self: Matcher<I, F, R, A, Pr>) => Matcher<I, AddOnly<F, WhenMatch<R, P>>, ApplyFilters<I, AddOnly<F, WhenMatch<R, P>>>, A | B, Pr>;
<R, P extends PredicateA<R>, B>(pattern: P, f: (_: NotMatch<R, P>) => B): <I, F, A, Pr>(self: Matcher<I, F, R, A, Pr>) => Matcher<I, AddOnly<F, WhenMatch<R, P>>, ApplyFilters<I, AddOnly<F, WhenMatch<R, P>>>, A | B, Pr>;
<P, SR, R, B>(schema: SafeSchema<P, SR>, f: (_: Exclude<R, ExtractMatch<R, SR>>) => B): <I, F, A, Pr>(self: Matcher<I, F, R, A, Pr>) => Matcher<I, AddOnly<F, ExtractMatch<R, P>>, ApplyFilters<I, AddOnly<F, ExtractMatch<R, P>>>, A | B, Pr>;
};
export declare const not: <R, const P extends PatternPrimitive<R> | PatternBase<R>, B>(pattern: P, f: (_: Exclude<R, ExtractMatch<R, RemoveInvalidPatterns<SafeSchemaR<PredToSchema<P>>>>>) => B) => <I, F, A, Pr>(self: Matcher<I, F, R, A, Pr>) => Matcher<I, AddOnly<F, ExtractMatch<R, RemoveInvalidPatterns<SafeSchemaP<ResolvePred<P>>>>>, ApplyFilters<I, AddOnly<F, ExtractMatch<R, RemoveInvalidPatterns<SafeSchemaP<ResolvePred<P>>>>>>, B | A, Pr>;
/**

@@ -258,3 +250,2 @@ * @since 1.0.0

type WhenMatch<R, P> = ExtractMatch<R, PForMatch<P>>;
type WhenSchemaMatch<R, P> = ExtractMatch<R, P>;
type NotMatch<R, P> = Exclude<R, ExtractMatch<R, PForExclude<P>>>;

@@ -264,7 +255,2 @@ type PForMatch<P> = RemoveInvalidPatterns<SafeSchemaP<ResolvePred<P>>>;

type PredicateA<A> = Predicate<A> | Refinement<A, A>;
type Narrow<A> = NarrowRaw<A>;
type NarrowRaw<A> = (A extends [] ? [] : never) | (A extends Function ? A : never) | {
[K in keyof A]: A[K] extends Function ? A[K] : A[K] extends SafeSchema<infer _P> ? A[K] : NarrowRaw<A[K]>;
} | (A extends Narrowable ? A : never);
type Narrowable = string | number | bigint | boolean;
type SafeSchemaP<A> = A extends SafeSchema<infer S, infer _> ? S : A extends Function ? A : A extends Record<string, any> ? {

@@ -282,5 +268,9 @@ [K in keyof A]: SafeSchemaP<A[K]>;

} : A;
type PatternBase<A> = A extends Array<infer T> ? Array<T | PredicateA<T> | SafeSchema<any>> : A extends Record<string, any> ? Partial<{
[K in keyof A]: PatternBase<A[K]> | PredicateA<A[K]> | SafeSchema<any>;
}> : A | PredicateA<A> | SafeSchema<any>;
type PatternBase<A> = A extends Array<infer _T> ? any : A extends Record<string, any> ? Partial<{
[K in keyof A]: PatternPrimitive<A[K]> | InnerPattern<A[K]>;
}> : A;
type PatternPrimitive<A> = PredicateA<A> | A | SafeSchema<any>;
type InnerPattern<A> = A extends Array<infer _T> ? any : A extends Record<string, any> ? Partial<{
[K in keyof A]: InnerPattern<A[K]> | PatternPrimitive<A[K]>;
}> : never;
type RemoveInvalidPatterns<P> = ValidPattern<P> extends true ? P : never;

@@ -287,0 +277,0 @@ type ValidPattern<P, Checked = never> = P extends SafeSchema<any> ? false : P extends Array<infer R> ? [R] extends [Checked] ? true : ValidPattern<R, Checked | R> : P extends Record<string, any> ? [

{
"name": "@effect/match",
"version": "0.18.5",
"version": "0.19.0",
"license": "MIT",

@@ -11,3 +11,3 @@ "repository": {

"@effect/data": "^0.12.2",
"@effect/schema": "^0.17.2"
"@effect/schema": "^0.17.4"
},

@@ -14,0 +14,0 @@ "main": "./index.js",

@@ -142,9 +142,10 @@ /**

*/
export const when: {
<R, P extends PatternBase<R>, B>(
pattern: Narrow<P>,
export const when =
<R, const P extends PatternPrimitive<R> | PatternBase<R>, B>(
pattern: P,
f: (_: WhenMatch<R, P>) => B,
): <I, F, A, Pr>(
) =>
<I, F, A, Pr>(
self: Matcher<I, F, R, A, Pr>,
) => Matcher<
): Matcher<
I,

@@ -155,34 +156,5 @@ AddWithout<F, PForExclude<P>>,

Pr
>
> =>
(self as any).add(new When(makeGuard(pattern), f as any))
<R, P extends PredicateA<R>, B>(pattern: P, f: (_: WhenMatch<R, P>) => B): <
I,
F,
A,
Pr,
>(
self: Matcher<I, F, R, A, Pr>,
) => Matcher<
I,
AddWithout<F, PForExclude<P>>,
ApplyFilters<I, AddWithout<F, PForExclude<P>>>,
A | B,
Pr
>
<P, SR, R, B>(
schema: SafeSchema<P, SR>,
f: (_: WhenSchemaMatch<R, P>) => B,
): <I, F, A, Pr>(
self: Matcher<I, F, R, A, Pr>,
) => Matcher<
I,
AddWithout<F, WhenSchemaMatch<R, P>>,
ApplyFilters<I, AddWithout<F, WhenSchemaMatch<R, P>>>,
A | B,
Pr
>
} = (pattern: any, f: Function) => (self: any) =>
self.add(new When(makeGuard(pattern), f as any))
/**

@@ -231,9 +203,10 @@ * @category combinators

*/
export const not: {
<R, P extends PatternBase<R>, B>(
pattern: Narrow<P>,
export const not =
<R, const P extends PatternPrimitive<R> | PatternBase<R>, B>(
pattern: P,
f: (_: NotMatch<R, P>) => B,
): <I, F, A, Pr>(
) =>
<I, F, A, Pr>(
self: Matcher<I, F, R, A, Pr>,
) => Matcher<
): Matcher<
I,

@@ -244,36 +217,5 @@ AddOnly<F, WhenMatch<R, P>>,

Pr
>
> =>
(self as any).add(new Not(makeGuard(pattern), f as any))
<R, P extends PredicateA<R>, B>(pattern: P, f: (_: NotMatch<R, P>) => B): <
I,
F,
A,
Pr,
>(
self: Matcher<I, F, R, A, Pr>,
) => Matcher<
I,
AddOnly<F, WhenMatch<R, P>>,
ApplyFilters<I, AddOnly<F, WhenMatch<R, P>>>,
A | B,
Pr
>
<P, SR, R, B>(
schema: SafeSchema<P, SR>,
f: (_: Exclude<R, ExtractMatch<R, SR>>) => B,
): <I, F, A, Pr>(
self: Matcher<I, F, R, A, Pr>,
) => Matcher<
I,
AddOnly<F, ExtractMatch<R, P>>,
ApplyFilters<I, AddOnly<F, ExtractMatch<R, P>>>,
A | B,
Pr
>
} =
(pattern: any, f: (_: never) => any) =>
(self: any): any =>
self.add(new Not(makeGuard(pattern), f as any))
/**

@@ -524,4 +466,2 @@ * @since 1.0.0

type WhenMatch<R, P> = ExtractMatch<R, PForMatch<P>>
type WhenSchemaMatch<R, P> = ExtractMatch<R, P>
type NotMatch<R, P> = Exclude<R, ExtractMatch<R, PForExclude<P>>>

@@ -535,18 +475,2 @@

type Narrow<A> = NarrowRaw<A>
type NarrowRaw<A> =
| (A extends [] ? [] : never)
| (A extends Function ? A : never)
| {
[K in keyof A]: A[K] extends Function
? A[K]
: A[K] extends SafeSchema<infer _P>
? A[K]
: NarrowRaw<A[K]>
}
| (A extends Narrowable ? A : never)
type Narrowable = string | number | bigint | boolean
type SafeSchemaP<A> = A extends SafeSchema<infer S, infer _>

@@ -588,10 +512,20 @@ ? S

type PatternBase<A> = A extends Array<infer T>
? Array<T | PredicateA<T> | SafeSchema<any>>
type PatternBase<A> = A extends Array<infer _T>
? any // TODO: improve array inference
: A extends Record<string, any>
? Partial<{
[K in keyof A]: PatternBase<A[K]> | PredicateA<A[K]> | SafeSchema<any>
[K in keyof A]: PatternPrimitive<A[K]> | InnerPattern<A[K]>
}>
: A | PredicateA<A> | SafeSchema<any>
: A
type PatternPrimitive<A> = PredicateA<A> | A | SafeSchema<any>
type InnerPattern<A> = A extends Array<infer _T>
? any // TODO: improve array inference
: A extends Record<string, any>
? Partial<{
[K in keyof A]: InnerPattern<A[K]> | PatternPrimitive<A[K]>
}>
: never
type RemoveInvalidPatterns<P> = ValidPattern<P> extends true ? P : never

@@ -598,0 +532,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet