Socket
Socket
Sign inDemoInstall

@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 0.0.8 to 0.0.9

62

index.d.ts

@@ -16,9 +16,9 @@ /**

*/
export type Matcher<Input, Remaining, RemainingApplied, Result, Provided> = TypeMatcher<Input, Remaining, RemainingApplied, Result> | ValueMatcher<Input, Remaining, RemainingApplied, Result, Provided>;
declare class TypeMatcher<Input, Remaining, RemainingApplied, Result> {
export type Matcher<Input, Filters, RemainingApplied, Result, Provided> = TypeMatcher<Input, Filters, RemainingApplied, Result> | ValueMatcher<Input, Filters, RemainingApplied, Result, Provided>;
declare class TypeMatcher<Input, Filters, Remaining, Result> {
readonly cases: ReadonlyArray<Case>;
readonly _tag = "TypeMatcher";
readonly _input: (_: Input) => unknown;
readonly _filters: (_: never) => Filters;
readonly _remaining: (_: never) => Remaining;
readonly _remainingApplied: (_: never) => RemainingApplied;
readonly _result: (_: never) => Result;

@@ -28,10 +28,10 @@ constructor(cases: ReadonlyArray<Case>);

}
declare class ValueMatcher<Input, Remaining, RemainingApplied, Result, Provided> {
declare class ValueMatcher<Input, Filters, Remaining, Result, Provided> {
readonly provided: Provided;
readonly value: E.Either<RemainingApplied, Provided>;
readonly value: E.Either<Remaining, Provided>;
readonly _tag = "ValueMatcher";
readonly _input: (_: Input) => unknown;
readonly _remaining: (_: never) => Remaining;
readonly _filters: (_: never) => Filters;
readonly _result: (_: never) => Result;
constructor(provided: Provided, value: E.Either<RemainingApplied, Provided>);
constructor(provided: Provided, value: E.Either<Remaining, Provided>);
add<I, R, RA, A, Pr>(_case: Case): ValueMatcher<I, R, RA, A, Pr>;

@@ -58,3 +58,3 @@ }

*/
export declare const type: <I>() => Matcher<I, I, I, never, never>;
export declare const type: <I>() => Matcher<I, Without<never>, I, never, never>;
/**

@@ -67,3 +67,3 @@ * @category constructors

*/
export declare const value: <I>(i: I) => Matcher<I, I, I, never, I>;
export declare const value: <I>(i: I) => Matcher<I, Without<never>, I, never, I>;
/**

@@ -76,4 +76,4 @@ * @category combinators

export declare const when: {
<RA, P extends PatternBase<RA>, B>(pattern: Narrow<P>, f: (_: WhenMatch<RA, P>) => B): <I, R, A, Pr>(self: Matcher<I, R, RA, A, Pr>) => Matcher<I, AddWithout<R, SafeSchemaR<PredToSchema<P>>>, ApplyFilters<AddWithout<R, SafeSchemaR<PredToSchema<P>>>>, A | B, Pr>;
<P, SR, RA, B>(schema: SafeSchema<P, SR>, f: (_: WhenSchemaMatch<RA, P>) => B): <I, R, A, Pr>(self: Matcher<I, R, RA, A, Pr>) => Matcher<I, AddWithout<R, WhenSchemaMatch<RA, P>>, ApplyFilters<AddWithout<R, WhenSchemaMatch<RA, P>>>, A | B, Pr>;
<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>;
<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>;
};

@@ -87,7 +87,7 @@ /**

export declare const tag: {
<RA, P extends Tags<RA> & (string | number | symbol | object | {}), B>(pattern: P, f: (_: Extract<RA, {
<R, P extends Tags<R> & (string | number | symbol | object | {}), B>(pattern: P, f: (_: Extract<R, {
readonly _tag: P;
}>) => B): <I, R, A, Pr>(self: Matcher<I, R, RA, A, Pr>) => Matcher<I, AddWithout<R, Extract<RA, {
}>) => B): <I, F, A, Pr>(self: Matcher<I, F, R, A, Pr>) => Matcher<I, AddWithout<F, Extract<R, {
_tag: P;
}>>, ApplyFilters<AddWithout<R, Extract<RA, {
}>>, ApplyFilters<I, AddWithout<F, Extract<R, {
_tag: P;

@@ -103,4 +103,4 @@ }>>>, A | B, Pr>;

export declare const not: {
<RA, P extends PatternBase<RA>, B>(pattern: Narrow<P>, f: (_: NotMatch<RA, P>) => B): <I, R, A, Pr>(self: Matcher<I, R, RA, A, Pr>) => Matcher<I, AddOnly<R, WhenMatch<RA, P>>, ApplyFilters<AddOnly<R, WhenMatch<RA, P>>>, A | B, Pr>;
<P, SR, RA, B>(schema: SafeSchema<P, SR>, f: (_: Exclude<RA, ExtractMatch<RA, SR>>) => B): <I, R, A, Pr>(self: Matcher<I, R, RA, A, Pr>) => Matcher<I, AddOnly<R, ExtractMatch<RA, P>>, ApplyFilters<AddOnly<R, ExtractMatch<RA, P>>>, A | B, Pr>;
<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>;
<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>;
};

@@ -232,3 +232,3 @@ /**

*/
export declare const either: <I, R, RA, A, Pr>(self: Matcher<I, R, RA, A, Pr>) => [Pr] extends [never] ? (input: I) => E.Either<RA, A> : E.Either<RA, A>;
export declare const either: <I, F, R, A, Pr>(self: Matcher<I, F, R, A, Pr>) => [Pr] extends [never] ? (input: I) => E.Either<R, A> : E.Either<R, A>;
/**

@@ -240,3 +240,3 @@ * @category conversions

*/
export declare const option: <I, R, RA, A, Pr>(self: Matcher<I, R, RA, A, Pr>) => [Pr] extends [never] ? (input: I) => O.Option<A> : O.Option<A>;
export declare const option: <I, F, R, A, Pr>(self: Matcher<I, F, R, A, Pr>) => [Pr] extends [never] ? (input: I) => O.Option<A> : O.Option<A>;
/**

@@ -248,6 +248,8 @@ * @category conversions

*/
export declare const exhaustive: <I, R, A, Pr>(self: Matcher<I, R, never, A, Pr>) => [Pr] extends [never] ? (u: I) => A : A;
type WhenMatch<R, P> = ExtractMatch<R, SafeSchemaP<ResolvePred<P>>>;
export declare const exhaustive: <I, F, A, Pr>(self: Matcher<I, F, never, A, Pr>) => [Pr] extends [never] ? (u: I) => A : A;
type WhenMatch<R, P> = ExtractMatch<R, PForMatch<P>>;
type WhenSchemaMatch<R, P> = ExtractMatch<R, P>;
type NotMatch<R, P> = Exclude<R, ExtractMatch<R, SafeSchemaR<PredToSchema<P>>>>;
type NotMatch<R, P> = Exclude<R, ExtractMatch<R, PForExclude<P>>>;
type PForMatch<P> = RemoveInvalidPatterns<SafeSchemaP<ResolvePred<P>>>;
type PForExclude<P> = RemoveInvalidPatterns<SafeSchemaR<PredToSchema<P>>>;
type PredicateA<A> = Predicate<A> | Refinement<A, any>;

@@ -274,15 +276,19 @@ type Narrow<A> = NarrowRaw<A> | PredicateA<any>;

}> : A | PredicateA<A> | SafeSchema<any>;
interface Without<A, X> {
type RemoveInvalidPatterns<P> = ValidPattern<P> extends true ? P : never;
type ValidPattern<P> = P extends SafeSchema<any> ? false : P extends Record<string, any> ? [
{
[K in keyof P]: ValidPattern<P[K]>;
} extends infer R ? Extract<R[keyof R], false> : never
] extends [never] ? true : false : true;
interface Without<X> {
readonly _tag: "Without";
readonly _A: A;
readonly _X: X;
}
interface Only<A, X> {
interface Only<X> {
readonly _tag: "Only";
readonly _A: A;
readonly _X: X;
}
type AddWithout<A, X> = A extends Without<infer P, infer WX> ? Without<P, X | WX> : A extends Only<infer P, infer OX> ? Only<P, Exclude<OX, X>> : Without<A, X>;
type AddOnly<A, X> = A extends Without<infer P, infer WX> ? X extends WX ? never : Only<P, X> : A extends Only<infer P, infer OX> ? X extends OX ? Only<P, X> : never : Only<A, X>;
type ApplyFilters<A> = A extends Only<any, infer X> ? X : A extends Without<infer P, infer X> ? Exclude<P, X> : A;
type AddWithout<A, X> = [A] extends [Without<infer WX>] ? Without<X | WX> : [A] extends [Only<infer OX>] ? Only<Exclude<OX, X>> : never;
type AddOnly<A, X> = [A] extends [Without<infer WX>] ? [X] extends [WX] ? never : Only<X> : [A] extends [Only<infer OX>] ? [X] extends [OX] ? Only<X> : never : never;
type ApplyFilters<I, A> = A extends Only<infer X> ? X : A extends Without<infer X> ? Exclude<I, X> : never;
type Tags<P> = P extends {

@@ -289,0 +295,0 @@ _tag: infer X;

@@ -20,4 +20,4 @@ "use strict";

this._input = _Function.identity;
this._filters = _Function.identity;
this._remaining = _Function.identity;
this._remainingApplied = _Function.identity;
this._result = _Function.identity;

@@ -35,3 +35,3 @@ }

this._input = _Function.identity;
this._remaining = _Function.identity;
this._filters = _Function.identity;
this._result = _Function.identity;

@@ -38,0 +38,0 @@ }

@@ -1,2 +0,2 @@

export type ExtractMatch<I, P> = ReplaceUnions<I, P> extends infer EI ? Extract<EI, P> : never;
export type ExtractMatch<I, P> = [ReplaceUnions<I, P>] extends [infer EI] ? Extract<EI, P> : never;
type IntersectOf<U extends unknown> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;

@@ -3,0 +3,0 @@ type Last<U extends any> = IntersectOf<U extends unknown ? (x: U) => void : never> extends (x: infer P) => void ? P : never;

{
"name": "@effect/match",
"version": "0.0.8",
"version": "0.0.9",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": {

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc