Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-pattern

Package Overview
Dependencies
Maintainers
1
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-pattern - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

6

lib/types/ExtractPreciseValue.d.ts
import { PatternType, __ } from './Pattern';
import { ExcludeIfContainsNever, LeastUpperBound } from './helpers';
export declare type ExtractPreciseValue<a, b> = b extends [] ? [] : [a, b] extends [[infer a1, infer a2, infer a3, infer a4, infer a5] | infer otherBranches, [infer b1, infer b2, infer b3, infer b4, infer b5]] ? [ExtractPreciseValue<a1, b1>, ExtractPreciseValue<a2, b2>, ExtractPreciseValue<a3, b3>, ExtractPreciseValue<a4, b4>, ExtractPreciseValue<a5, b5>] : [a, b] extends [[infer a1, infer a2, infer a3, infer a4] | infer otherBranches, [infer b1, infer b2, infer b3, infer b4]] ? [ExtractPreciseValue<a1, b1>, ExtractPreciseValue<a2, b2>, ExtractPreciseValue<a3, b3>, ExtractPreciseValue<a4, b4>] : [a, b] extends [[infer a1, infer a2, infer a3] | infer otherBranches, [infer b1, infer b2, infer b3]] ? [ExtractPreciseValue<a1, b1>, ExtractPreciseValue<a2, b2>, ExtractPreciseValue<a3, b3>] : [a, b] extends [[infer a1, infer a2] | infer otherBranches, [infer b1, infer b2]] ? [ExtractPreciseValue<a1, b1>, ExtractPreciseValue<a2, b2>] : [a, b] extends [(infer a1)[], (infer b1)[]] ? ExtractPreciseValue<a1, b1>[] : [a, b] extends [Map<infer ak, infer av>, Map<infer bk, infer bv>] ? Map<ExtractPreciseValue<ak, bk>, ExtractPreciseValue<av, bv>> : [a, b] extends [Set<infer av>, Set<infer bv>] ? Set<ExtractPreciseValue<av, bv>> : b extends typeof __ ? a : b extends {
export declare type ExtractPreciseValue<a, b> = ExcludeIfContainsNever<b extends [] ? [] : b extends typeof __ ? a : b extends {
valueKind: PatternType.Not;
value: infer b1;
} ? Exclude<a, b1> : b extends object ? b extends a ? b : a extends b ? a : ExcludeIfContainsNever<{
} ? Exclude<a, b1> : [a, b] extends [([infer a1, infer a2, infer a3, infer a4, infer a5] | infer otherBranches), [infer b1, infer b2, infer b3, infer b4, infer b5]] ? [ExtractPreciseValue<a1, b1>, ExtractPreciseValue<a2, b2>, ExtractPreciseValue<a3, b3>, ExtractPreciseValue<a4, b4>, ExtractPreciseValue<a5, b5>] : [a, b] extends [[infer a1, infer a2, infer a3, infer a4] | infer otherBranches, [infer b1, infer b2, infer b3, infer b4]] ? [ExtractPreciseValue<a1, b1>, ExtractPreciseValue<a2, b2>, ExtractPreciseValue<a3, b3>, ExtractPreciseValue<a4, b4>] : [a, b] extends [[infer a1, infer a2, infer a3] | infer otherBranches, [infer b1, infer b2, infer b3]] ? [ExtractPreciseValue<a1, b1>, ExtractPreciseValue<a2, b2>, ExtractPreciseValue<a3, b3>] : [a, b] extends [[infer a1, infer a2] | infer otherBranches, [infer b1, infer b2]] ? [ExtractPreciseValue<a1, b1>, ExtractPreciseValue<a2, b2>] : [a, b] extends [(infer a1)[], (infer b1)[]] ? ExtractPreciseValue<a1, b1>[] : [a, b] extends [Map<infer ak, infer av>, Map<infer bk, infer bv>] ? Map<ExtractPreciseValue<ak, bk>, ExtractPreciseValue<av, bv>> : [a, b] extends [Set<infer av>, Set<infer bv>] ? Set<ExtractPreciseValue<av, bv>> : b extends object ? a extends object ? b extends a ? b : a extends b ? a : {
[k in keyof Required<a>]: k extends keyof b ? ExtractPreciseValue<a[k], b[k]> : a[k];
}> : LeastUpperBound<a, b>;
} : never : LeastUpperBound<a, b>>;

@@ -15,5 +15,5 @@ export declare type ValueOf<a> = a[keyof a];

**/
export declare type ExcludeIfContainsNever<a> = ValueOf<{
export declare type ExcludeIfContainsNever<a> = a extends any[] | Map<any, any> | Set<any> ? a : a extends object ? {
[k in keyof a]-?: a[k] extends never ? 'exclude' : 'include';
}> extends 'include' ? a : never;
}[keyof a] extends 'include' ? a : never : a;
export declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;

@@ -38,3 +38,2 @@ import { Pattern, SelectPattern, GuardValue } from './Pattern';

export declare type ExtractSelections<a, p extends Pattern<a>> = UnionToIntersection<FindSelected<MatchedValue<a, p>, p>>;
export declare type PatternHandler<a, p extends Pattern<a>, c> = (value: MatchedValue<a, p>, selections: ExtractSelections<a, p>) => c;
export declare type Unset = '@match/unset';

@@ -52,3 +51,3 @@ export declare type PickReturnValue<a, b> = a extends Unset ? b : a;

**/
with<p extends Pattern<a>, c>(pattern: p, handler: PatternHandler<a, p, PickReturnValue<b, c>>): Match<a, PickReturnValue<b, c>>;
with<p extends Pattern<a>, c>(pattern: p, handler: (value: MatchedValue<a, p>, selections: ExtractSelections<a, p>) => PickReturnValue<b, c>): Match<a, PickReturnValue<b, c>>;
with<pat extends Pattern<a>, pred extends (value: MatchedValue<a, pat>) => unknown, c>(pattern: pat, predicate: pred, handler: (value: GuardValue<pred>, selections: ExtractSelections<a, pat>) => PickReturnValue<b, c>): Match<a, PickReturnValue<b, c>>;

@@ -55,0 +54,0 @@ with<pat extends Pattern<a>, pred extends (value: MatchedValue<a, pat>) => unknown, pred2 extends (value: GuardValue<pred>) => unknown, c>(pattern: pat, predicate: pred, predicate2: pred2, handler: (value: GuardValue<pred2>, selections: ExtractSelections<a, pat>) => PickReturnValue<b, c>): Match<a, PickReturnValue<b, c>>;

{
"name": "ts-pattern",
"version": "0.2.1",
"version": "0.2.2",
"description": "Typescript pattern matching library",

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

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