@effect/match
Advanced tools
Comparing version 0.0.5 to 0.0.6
/** | ||
* @since 1.0.0 | ||
*/ | ||
import type { ExtractMatch } from "@effect/match/internal/ExtractMatch"; | ||
import * as E from "@fp-ts/core/Either"; | ||
@@ -72,3 +73,3 @@ import * as O from "@fp-ts/core/Option"; | ||
<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, P>, ApplyFilters<AddWithout<R, SR>>, 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>; | ||
}; | ||
@@ -97,4 +98,4 @@ /** | ||
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, SafeSchemaP<ResolvePred<P>>>, ApplyFilters<AddOnly<R, SafeSchemaP<ResolvePred<P>>>>, A | B, Pr>; | ||
<P, SR, RA, B>(schema: SafeSchema<P, SR>, f: (_: Exclude<RA, SR>) => B): <I, R, A, Pr>(self: Matcher<I, R, RA, A, Pr>) => Matcher<I, AddOnly<R, P>, ApplyFilters<AddOnly<R, P>>, A | B, Pr>; | ||
<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>; | ||
}; | ||
@@ -241,5 +242,5 @@ /** | ||
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> = Replace<TryExtract<R, SafeSchemaP<ResolvePred<P>>>, SafeSchemaP<ResolvePred<P>>>; | ||
type WhenSchemaMatch<R, P> = Replace<TryExtract<R, P>, P>; | ||
type NotMatch<R, P> = Exclude<R, SafeSchemaR<PredToSchema<P>>>; | ||
type WhenMatch<R, P> = ExtractMatch<R, SafeSchemaP<ResolvePred<P>>>; | ||
type WhenSchemaMatch<R, P> = ExtractMatch<R, P>; | ||
type NotMatch<R, P> = Exclude<R, ExtractMatch<R, SafeSchemaR<PredToSchema<P>>>>; | ||
type PredicateA<A> = Predicate<A> | Refinement<A, any>; | ||
@@ -263,16 +264,5 @@ type Narrow<A> = NarrowRaw<A> | PredicateA<any>; | ||
} : A; | ||
type ExpandTuples<A> = A extends Array<infer I> ? Array<I> | A : A extends Record<string, any> ? { | ||
[K in keyof A]: ExpandTuples<A[K]>; | ||
} : A; | ||
type PatternBase<A> = A extends Record<string, any> ? Partial<{ | ||
[K in keyof A]: PatternBase<A[K]> | PredicateA<A[K]> | SafeSchema<any>; | ||
}> : A | PredicateA<A> | SafeSchema<any>; | ||
type WithoutLiterals<A> = A extends string ? string : A extends number ? number : A extends bigint ? bigint : A extends boolean ? boolean : A extends Record<string, any> ? { | ||
[K in keyof A]: WithoutLiterals<A[K]>; | ||
} : A; | ||
type ExtractWithoutLiterals<A, E> = A extends WithoutLiterals<E> ? A : never; | ||
type TryExtract<A, E> = Extract<A, ExpandTuples<E>> extends never ? ExtractWithoutLiterals<A, ExpandTuples<E>> : Extract<A, ExpandTuples<E>>; | ||
type Replace<A, B> = A extends Record<string | number, any> ? { | ||
[K in keyof A]: K extends keyof B ? Replace<A[K], B[K]> : A[K]; | ||
} : B extends A ? B : A; | ||
interface Without<A, X> { | ||
@@ -290,3 +280,3 @@ readonly _tag: "Without"; | ||
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 ApplyFilters<A> = A extends Only<any, infer X> ? X : A extends Without<infer P, infer X> ? Exclude<P, ExtractMatch<P, X>> : A; | ||
type Tags<P> = P extends { | ||
@@ -293,0 +283,0 @@ _tag: infer X; |
@@ -15,6 +15,2 @@ "use strict"; | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
class TypeMatcher { | ||
@@ -21,0 +17,0 @@ constructor(cases) { |
{ | ||
"name": "@effect/match", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -102,6 +102,9 @@ <h3 align="center"> | ||
This library is built upon the great work of [@fp-ts/schema](https://github.com/fp-ts/schema). | ||
This library is built upon the great work of: | ||
- [@fp-ts/schema](https://github.com/fp-ts/schema). | ||
- [ts-pattern](https://github.com/gvergnaud/ts-pattern) | ||
## License | ||
The MIT License (MIT) |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58779
14
863
110