ts-pattern
Advanced tools
Comparing version 5.3.1 to 5.4.0
@@ -1,2 +0,2 @@ | ||
import { Compute, Iterator, UpdateAt } from './helpers.js'; | ||
import { Iterator, UpdateAt, ValueOf } from './helpers.js'; | ||
export type BuildMany<data, xs extends readonly any[]> = xs extends any ? BuildOne<data, xs> : never; | ||
@@ -9,11 +9,9 @@ type BuildOne<data, xs extends readonly any[]> = xs extends [ | ||
...infer tail | ||
] ? BuildOne<Update<data, value, Extract<path, readonly PropertyKey[]>>, tail> : data; | ||
type Update<data, value, path> = path extends readonly [ | ||
] ? BuildOne<SetDeep<data, value, path>, tail> : data; | ||
export type SetDeep<data, value, path> = path extends readonly [ | ||
infer head, | ||
...infer tail | ||
] ? data extends readonly [any, ...any] ? head extends number ? UpdateAt<data, Iterator<head>, Update<data[head], value, tail>> : never : data extends readonly (infer a)[] ? Update<a, value, tail>[] : data extends Set<infer a> ? Set<Update<a, value, tail>> : data extends Map<infer k, infer v> ? Map<k, Update<v, value, tail>> : head extends keyof data ? Compute<{ | ||
[k in Exclude<keyof data, head>]: data[k]; | ||
} & { | ||
[k in head]: Update<data[k], value, tail>; | ||
}> : data : value; | ||
] ? data extends readonly any[] ? data extends readonly [any, ...any] ? head extends number ? UpdateAt<data, Iterator<head>, SetDeep<data[head], value, tail>> : never : SetDeep<ValueOf<data>, value, tail>[] : data extends Set<infer a> ? Set<SetDeep<a, value, tail>> : data extends Map<infer k, infer v> ? Map<k, SetDeep<v, value, tail>> : head extends keyof data ? { | ||
[k in keyof data]-?: k extends head ? SetDeep<data[head], value, tail> : data[k]; | ||
} : data : value; | ||
export {}; |
@@ -84,3 +84,3 @@ import { BuildMany } from './BuildMany.js'; | ||
] ? [...FindUnions<a1, p1, [...path, 0]>, ...FindUnions<a2, p2, [...path, 1]>] : [a, p] extends [readonly [infer a1], readonly [infer p1]] ? FindUnions<a1, p1, [...path, 0]> : p extends readonly [] | readonly [any, ...any] | readonly [...any, any] ? IsStrictArray<Extract<a, readonly any[]>> extends false ? [] : [ | ||
MaybeAddReadonly<(a extends readonly [any, ...any] | readonly [...any, any] ? never : []) | (p extends readonly [...any, any] ? [...Extract<a, readonly any[]>, ValueOf<a>] : [ValueOf<a>, ...Extract<a, readonly any[]>]), IsReadonlyArray<a>> extends infer aUnion ? { | ||
ArrayToVariadicUnion<a, p> extends infer aUnion ? { | ||
cases: aUnion extends any ? { | ||
@@ -95,2 +95,3 @@ value: aUnion; | ||
}>> : []; | ||
export type ArrayToVariadicUnion<input, excluded> = MaybeAddReadonly<(input extends readonly [any, ...any] | readonly [...any, any] ? never : []) | (excluded extends readonly [...any, any] ? [...Extract<input, readonly any[]>, ValueOf<input>] : [ValueOf<input>, ...Extract<input, readonly any[]>]), IsReadonlyArray<input>>; | ||
export type Distribute<unions extends readonly any[]> = unions extends readonly [ | ||
@@ -97,0 +98,0 @@ { |
@@ -86,3 +86,3 @@ import { DeepExclude } from './DeepExclude.js'; | ||
select: InvertPatternForExcludeInternal<subpattern, i, empty>; | ||
array: i extends readonly (infer ii)[] ? InvertPatternForExcludeInternal<subpattern, ii, empty>[] : empty; | ||
array: i extends readonly (infer ii)[] ? MaybeAddReadonly<InvertPatternForExcludeInternal<subpattern, ii, empty>[], IsReadonlyArray<i>> : empty; | ||
map: subpattern extends [infer pk, infer pv] ? i extends Map<infer ik, infer iv> ? Map<InvertPatternForExcludeInternal<pk, ik, empty>, InvertPatternForExcludeInternal<pv, iv, empty>> : empty : empty; | ||
@@ -89,0 +89,0 @@ set: i extends Set<infer iv> ? Set<InvertPatternForExcludeInternal<subpattern, iv, empty>> : empty; |
{ | ||
"name": "ts-pattern", | ||
"version": "5.3.1", | ||
"version": "5.4.0", | ||
"description": " The exhaustive Pattern Matching library for TypeScript.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
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
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
416845