diff --git a/README.md b/README.md index 92498579..47adf39b 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,9 @@ Write **better** and **safer conditions**. Pattern matching lets you express com - **Typesafe**, with helpful [type inference](#type-inference). - **Exhaustiveness checking** support, enforcing that you are matching every possible case with [`.exhaustive()`](#exhaustive). - Use [patterns](#patterns) to **validate** the shape of your data with [`isMatching`](#ismatching). -- **Expressive API**, with catch-all and type specific **wildcards**: [`P._`](#P_-wildcard), [`P.string`](#Pstring-wildcard), [`P.number`](#Pnumber-wildcard), etc. -- Supports [**predicates**](#Pwhen-patterns), [**unions**](#Punion-patterns), [**intersections**](#Pintersection-patterns) and [**exclusion**](#Pnot-patterns) patterns for non-trivial cases. -- Supports properties selection, via the [`P.select(name?)`](#Pselect-patterns) function. +- **Expressive API**, with catch-all and type specific **wildcards**: [`P._`](#p_-wildcard), [`P.string`](#pstring-wildcard), [`P.number`](#pnumber-wildcard), etc. +- Supports [**predicates**](#pwhen-patterns), [**unions**](#punion-patterns), [**intersections**](#pintersection-patterns) and [**exclusion**](#pnot-patterns) patterns for non-trivial cases. +- Supports properties selection, via the [`P.select(name?)`](#pselect-patterns) function. - Tiny bundle footprint ([**only ~2kB**](https://bundlephobia.com/package/ts-pattern)). ## What is Pattern Matching? @@ -111,19 +111,19 @@ TS-Pattern assumes that [Strict Mode](https://www.typescriptlang.org/tsconfig#st - [Tuples (arrays)](#tuples-arrays) - [Sets](#pset-patterns) - [Maps](#pmap-patterns) - - [`P.array` patterns](#Parray-patterns) - - [`P.when` patterns](#Pwhen-patterns) - - [`P.not` patterns](#Pnot-patterns) - - [`P.select` patterns](#Pselect-patterns) - - [`P.optional` patterns](#Poptional-patterns) - - [`P.instanceOf` patterns](#Pinstanceof-patterns) - - [`P.union` patterns](#Punion-patterns) - - [`P.intersection` patterns](#Pintersection-patterns) + - [`P.array` patterns](#parray-patterns) + - [`P.when` patterns](#pwhen-patterns) + - [`P.not` patterns](#pnot-patterns) + - [`P.select` patterns](#pselect-patterns) + - [`P.optional` patterns](#poptional-patterns) + - [`P.instanceOf` patterns](#pinstanceof-patterns) + - [`P.union` patterns](#punion-patterns) + - [`P.intersection` patterns](#pintersection-patterns) - [`P.string` predicates](#pstring-predicates) - [`P.number` and `P.bigint` predicates](#pnumber-and-pbigint-predicates) - [Types](#types) - - [`P.infer`](#Pinfer) - - [`P.Pattern`](#PPattern) + - [`P.infer`](#pinfer) + - [`P.Pattern`](#pPattern) - [Type inference](#type-inference) - [Inspirations](#inspirations) @@ -684,7 +684,7 @@ export function isMatching

>( A pattern is a description of the expected shape of your input value. -Patterns can be regular JavaScript values (`"some string"`, `10`, `true`, ...), data structures ([objects](#objects), [arrays](#tuples-arrays), ...), wildcards ([`P._`](#P_-wildcard), [`P.string`](#pstring-wildcard), [`P.number`](#pnumber-wildcard), ...), or special matcher functions ([`P.not`](#pnot-patterns), +Patterns can be regular JavaScript values (`"some string"`, `10`, `true`, ...), data structures ([objects](#objects), [arrays](#tuples-arrays), ...), wildcards ([`P._`](#p_-wildcard), [`P.string`](#pstring-wildcard), [`P.number`](#pnumber-wildcard), ...), or special matcher functions ([`P.not`](#pnot-patterns), [`P.when`](#pwhen-patterns), [`P.select`](#pselect-patterns), ...). All wildcards and matcher functions can be imported either as `Pattern` or as `P` from the `ts-pattern` module. diff --git a/src/patterns.ts b/src/patterns.ts index 450cc38f..840342b9 100644 --- a/src/patterns.ts +++ b/src/patterns.ts @@ -85,7 +85,7 @@ export type unstable_Matcher< * `P.infer` will return the type of the value * matched by this pattern. * - * [Read the documentation for `P.infer` on GitHub](https://github.com/gvergnaud/ts-pattern#Pinfer) + * [Read the documentation for `P.infer` on GitHub](https://github.com/gvergnaud/ts-pattern#pinfer) * * @example * const userPattern = { name: P.stringĀ } @@ -100,7 +100,7 @@ export type infer> = InvertPattern< * `P.narrow` will narrow the input type to only keep * the set of values that are compatible with the provided pattern type. * - * [Read the documentation for `P.narrow` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnarrow) + * [Read the documentation for `P.narrow` on GitHub](https://github.com/gvergnaud/ts-pattern#pnarrow) * * @example * type Input = ['a' | 'b' | 'c', 'a' | 'b' | 'c'] @@ -151,7 +151,7 @@ function arrayChainable>( * `P.optional(subpattern)` takes a sub pattern and returns a pattern which matches if the * key is undefined or if it is defined and the sub pattern matches its value. * - * [Read the documentation for `P.optional` on GitHub](https://github.com/gvergnaud/ts-pattern#Poptional-patterns) + * [Read the documentation for `P.optional` on GitHub](https://github.com/gvergnaud/ts-pattern#poptional-patterns) * * @example * match(value) @@ -199,7 +199,7 @@ type WithDefault = [a] extends [never] ? b : a; * `P.array(subpattern)` takes a sub pattern and returns a pattern, which matches * arrays if all their elements match the sub pattern. * - * [Read the documentation for `P.array` on GitHub](https://github.com/gvergnaud/ts-pattern#Parray-patterns) + * [Read the documentation for `P.array` on GitHub](https://github.com/gvergnaud/ts-pattern#parray-patterns) * * @example * match(value) @@ -252,7 +252,7 @@ export function array( * `P.set(subpattern)` takes a sub pattern and returns a pattern that matches * sets if all their elements match the sub pattern. * - * [Read `P.set` documentation on GitHub](https://github.com/gvergnaud/ts-pattern#Pset-patterns) + * [Read `P.set` documentation on GitHub](https://github.com/gvergnaud/ts-pattern#pset-patterns) * * @example * match(value) @@ -312,7 +312,7 @@ const setEvery = (set: Set, predicate: (value: T) => boolean) => { * `P.set(subpattern)` takes a sub pattern and returns a pattern that matches * sets if all their elements match the sub pattern. * - * [Read `P.set` documentation on GitHub](https://github.com/gvergnaud/ts-pattern#Pset-patterns) + * [Read `P.set` documentation on GitHub](https://github.com/gvergnaud/ts-pattern#pset-patterns) * * @example * match(value) @@ -387,7 +387,7 @@ const mapEvery = ( * `P.intersection(...patterns)` returns a pattern which matches * only if **every** patterns provided in parameter match the input. * - * [Read the documentation for `P.intersection` on GitHub](https://github.com/gvergnaud/ts-pattern#Pintersection-patterns) + * [Read the documentation for `P.intersection` on GitHub](https://github.com/gvergnaud/ts-pattern#pintersection-patterns) * * @example * match(value) @@ -429,7 +429,7 @@ export function intersection< * `P.union(...patterns)` returns a pattern which matches * if **at least one** of the patterns provided in parameter match the input. * - * [Read the documentation for `P.union` on GitHub](https://github.com/gvergnaud/ts-pattern#Punion-patterns) + * [Read the documentation for `P.union` on GitHub](https://github.com/gvergnaud/ts-pattern#punion-patterns) * * @example * match(value) @@ -469,7 +469,7 @@ export function union< * `P.not(pattern)` returns a pattern which matches if the sub pattern * doesn't match. * - * [Read the documentation for `P.not` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnot-patterns) + * [Read the documentation for `P.not` on GitHub](https://github.com/gvergnaud/ts-pattern#pnot-patterns) * * @example * match<{ a: string | number }>(value) @@ -496,7 +496,7 @@ export function not< * `P.when((value) => boolean)` returns a pattern which matches * if the predicate returns true for the current input. * - * [Read the documentation for `P.when` on GitHub](https://github.com/gvergnaud/ts-pattern#Pwhen-patterns) + * [Read the documentation for `P.when` on GitHub](https://github.com/gvergnaud/ts-pattern#pwhen-patterns) * * @example * match<{ age: number }>(value) @@ -531,7 +531,7 @@ export function when unknown>( * `P.select()` is a pattern which will always match, * and will inject the selected piece of input in the handler function. * - * [Read the documentation for `P.select` on GitHub](https://github.com/gvergnaud/ts-pattern#Pselect-patterns) + * [Read the documentation for `P.select` on GitHub](https://github.com/gvergnaud/ts-pattern#pselect-patterns) * * @example * match<{ age: number }>(value) @@ -636,7 +636,7 @@ function isInstanceOf(classConstructor: T) { /** * `P.any` is a wildcard pattern, matching **any value**. * - * [Read the documentation for `P.any` on GitHub](https://github.com/gvergnaud/ts-pattern#P_-wildcard) + * [Read the documentation for `P.any` on GitHub](https://github.com/gvergnaud/ts-pattern#p_-wildcard) * * @example * match(value) @@ -648,7 +648,7 @@ export const any: AnyPattern = chainable(when(isUnknown)); * `P._` is a wildcard pattern, matching **any value**. * It's an alias to `P.any`. * - * [Read the documentation for `P._` on GitHub](https://github.com/gvergnaud/ts-pattern#P_-wildcard) + * [Read the documentation for `P._` on GitHub](https://github.com/gvergnaud/ts-pattern#p_-wildcard) * * @example * match(value) @@ -659,7 +659,7 @@ export const _ = any; /** * `P.string.startsWith(start)` is a pattern, matching **strings** starting with `start`. * - * [Read the documentation for `P.string.startsWith` on GitHub](https://github.com/gvergnaud/ts-pattern#PstringstartsWith) + * [Read the documentation for `P.string.startsWith` on GitHub](https://github.com/gvergnaud/ts-pattern#pstringstartsWith) * * @example * match(value) @@ -674,7 +674,7 @@ const startsWith = ( /** * `P.string.endsWith(end)` is a pattern, matching **strings** ending with `end`. * - * [Read the documentation for `P.string.endsWith` on GitHub](https://github.com/gvergnaud/ts-pattern#PstringendsWith) + * [Read the documentation for `P.string.endsWith` on GitHub](https://github.com/gvergnaud/ts-pattern#pstringendsWith) * * @example * match(value) @@ -688,7 +688,7 @@ const endsWith = ( /** * `P.string.minLength(min)` is a pattern, matching **strings** with at least `min` characters. * - * [Read the documentation for `P.string.minLength` on GitHub](https://github.com/gvergnaud/ts-pattern#PstringminLength) + * [Read the documentation for `P.string.minLength` on GitHub](https://github.com/gvergnaud/ts-pattern#pstringminLength) * * @example * match(value) @@ -700,7 +700,7 @@ const minLength = (min: min) => /** * `P.string.maxLength(max)` is a pattern, matching **strings** with at most `max` characters. * - * [Read the documentation for `P.string.maxLength` on GitHub](https://github.com/gvergnaud/ts-pattern#PstringmaxLength) + * [Read the documentation for `P.string.maxLength` on GitHub](https://github.com/gvergnaud/ts-pattern#pstringmaxLength) * * @example * match(value) @@ -712,7 +712,7 @@ const maxLength = (max: max) => /** * `P.string.includes(substr)` is a pattern, matching **strings** containing `substr`. * - * [Read the documentation for `P.string.includes` on GitHub](https://github.com/gvergnaud/ts-pattern#Pstringincludes) + * [Read the documentation for `P.string.includes` on GitHub](https://github.com/gvergnaud/ts-pattern#pstringincludes) * * @example * match(value) @@ -726,7 +726,7 @@ const includes = ( /** * `P.string.regex(expr)` is a pattern, matching **strings** that `expr` regular expression. * - * [Read the documentation for `P.string.regex` on GitHub](https://github.com/gvergnaud/ts-pattern#Pstringregex) + * [Read the documentation for `P.string.regex` on GitHub](https://github.com/gvergnaud/ts-pattern#pstringregex) * * @example * match(value) @@ -757,7 +757,7 @@ const stringChainable = >( /** * `P.string` is a wildcard pattern, matching any **string**. * - * [Read the documentation for `P.string` on GitHub](https://github.com/gvergnaud/ts-pattern#Pstring-wildcard) + * [Read the documentation for `P.string` on GitHub](https://github.com/gvergnaud/ts-pattern#pstring-wildcard) * * @example * match(value) @@ -769,7 +769,7 @@ export const string: StringPattern = stringChainable(when(isString)); * `P.number.between(min, max)` matches **numbers** between `min` and `max`, * equal to min or equal to max. * - * [Read the documentation for `P.number.between` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberbetween) + * [Read the documentation for `P.number.between` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberbetween) * * @example * match(value) @@ -788,7 +788,7 @@ export const between = < /** * `P.number.lt(max)` matches **numbers** smaller than `max`. * - * [Read the documentation for `P.number.lt` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberlt) + * [Read the documentation for `P.number.lt` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberlt) * * @example * match(value) @@ -802,7 +802,7 @@ export const lt = ( /** * `P.number.gt(min)` matches **numbers** greater than `min`. * - * [Read the documentation for `P.number.gt` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumbergt) + * [Read the documentation for `P.number.gt` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumbergt) * * @example * match(value) @@ -816,7 +816,7 @@ export const gt = ( /** * `P.number.lte(max)` matches **numbers** smaller than or equal to `max`. * - * [Read the documentation for `P.number.lte` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberlte) + * [Read the documentation for `P.number.lte` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberlte) * * @example * match(value) @@ -830,7 +830,7 @@ export const lte = ( /** * `P.number.gte(min)` matches **numbers** greater than or equal to `min`. * - * [Read the documentation for `P.number.gte` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumbergte) + * [Read the documentation for `P.number.gte` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumbergte) * * @example * match(value) @@ -844,7 +844,7 @@ export const gte = ( /** * `P.number.int` matches **integer** numbers. * - * [Read the documentation for `P.number.int` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberint) + * [Read the documentation for `P.number.int` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberint) * * @example * match(value) @@ -856,7 +856,7 @@ export const int = (): GuardExcludeP => /** * `P.number.finite` matches **finite numbers**. * - * [Read the documentation for `P.number.finite` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberfinite) + * [Read the documentation for `P.number.finite` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberfinite) * * @example * match(value) @@ -868,7 +868,7 @@ export const finite = (): GuardExcludeP => /** * `P.number.positive` matches **positive** numbers. * - * [Read the documentation for `P.number.positive` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberpositive) + * [Read the documentation for `P.number.positive` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberpositive) * * @example * match(value) @@ -880,7 +880,7 @@ export const positive = (): GuardExcludeP => /** * `P.number.negative` matches **negative** numbers. * - * [Read the documentation for `P.number.negative` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumbernegative) + * [Read the documentation for `P.number.negative` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumbernegative) * * @example * match(value) @@ -908,7 +908,7 @@ const numberChainable = >( /** * `P.number` is a wildcard pattern, matching any **number**. * - * [Read the documentation for `P.number` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumber-wildcard) + * [Read the documentation for `P.number` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumber-wildcard) * * @example * match(value) @@ -920,7 +920,7 @@ export const number: NumberPattern = numberChainable(when(isNumber)); * `P.bigint.between(min, max)` matches **bigint** between `min` and `max`, * equal to min or equal to max. * - * [Read the documentation for `P.bigint.between` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberbetween) + * [Read the documentation for `P.bigint.between` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberbetween) * * @example * match(value) @@ -939,7 +939,7 @@ export const betweenBigInt = < /** * `P.bigint.lt(max)` matches **bigint** smaller than `max`. * - * [Read the documentation for `P.bigint.lt` on GitHub](https://github.com/gvergnaud/ts-pattern#bigintlt) + * [Read the documentation for `P.bigint.lt` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberlt) * * @example * match(value) @@ -953,7 +953,7 @@ export const ltBigInt = ( /** * `P.bigint.gt(min)` matches **bigint** greater than `min`. * - * [Read the documentation for `P.bigint.gt` on GitHub](https://github.com/gvergnaud/ts-pattern#bigintgt) + * [Read the documentation for `P.bigint.gt` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumbergt) * * @example * match(value) @@ -967,7 +967,7 @@ export const gtBigInt = ( /** * `P.bigint.lte(max)` matches **bigint** smaller than or equal to `max`. * - * [Read the documentation for `P.bigint.lte` on GitHub](https://github.com/gvergnaud/ts-pattern#bigintlte) + * [Read the documentation for `P.bigint.lte` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberlte) * * @example * match(value) @@ -981,7 +981,7 @@ export const lteBigInt = ( /** * `P.bigint.gte(min)` matches **bigint** greater than or equal to `min`. * - * [Read the documentation for `P.bigint.gte` on GitHub](https://github.com/gvergnaud/ts-pattern#Pbigintgte) + * [Read the documentation for `P.bigint.gte` on GitHub](https://github.com/gvergnaud/ts-pattern#pbigintgte) * * @example * match(value) @@ -995,7 +995,7 @@ export const gteBigInt = ( /** * `P.bigint.positive` matches **positive** bigints. * - * [Read the documentation for `P.bigint.positive` on GitHub](https://github.com/gvergnaud/ts-pattern#Pbigintpositive) + * [Read the documentation for `P.bigint.positive` on GitHub](https://github.com/gvergnaud/ts-pattern#pbigintpositive) * * @example * match(value) @@ -1007,7 +1007,7 @@ export const positiveBigInt = (): GuardExcludeP => /** * `P.bigint.negative` matches **negative** bigints. * - * [Read the documentation for `P.bigint.negative` on GitHub](https://github.com/gvergnaud/ts-pattern#Pbigintnegative) + * [Read the documentation for `P.bigint.negative` on GitHub](https://github.com/gvergnaud/ts-pattern#pbigintnegative) * * @example * match(value) @@ -1035,7 +1035,7 @@ const bigintChainable = >( /** * `P.bigint` is a wildcard pattern, matching any **bigint**. * - * [Read the documentation for `P.bigint` on GitHub](https://github.com/gvergnaud/ts-pattern#bigint-wildcard) + * [Read the documentation for `P.bigint` on GitHub](https://github.com/gvergnaud/ts-pattern#number-wildcard) * * @example * .with(P.bigint, () => 'will match on bigints') @@ -1075,7 +1075,7 @@ export const nullish: NullishPattern = chainable(when(isNullish)); /** * `P.instanceOf(SomeClass)` is a pattern matching instances of a given class. * - * [Read the documentation for `P.instanceOf` on GitHub](https://github.com/gvergnaud/ts-pattern#Pinstanceof-patterns) + * [Read the documentation for `P.instanceOf` on GitHub](https://github.com/gvergnaud/ts-pattern#pinstanceof-patterns) * * @example * .with(P.instanceOf(SomeClass), () => 'will match on SomeClass instances') @@ -1090,7 +1090,7 @@ export function instanceOf( * `P.shape(somePattern)` lets you call methods like `.optional()`, `.and`, `.or` and `.select()` * On structural patterns, like objects and arrays. * - * [Read the documentation for `P.shape` on GitHub](https://github.com/gvergnaud/ts-pattern#Pshape-patterns) + * [Read the documentation for `P.shape` on GitHub](https://github.com/gvergnaud/ts-pattern#pshape-patterns) * * @example * .with( diff --git a/src/types/Pattern.ts b/src/types/Pattern.ts index 1ae6bc5e..47d7821c 100644 --- a/src/types/Pattern.ts +++ b/src/types/Pattern.ts @@ -206,7 +206,7 @@ export type Chainable = p & * `.optional()` returns a pattern which matches if the * key is undefined or if it is defined and the previous pattern matches its value. * - * [Read the documentation for `P.optional` on GitHub](https://github.com/gvergnaud/ts-pattern#Poptional-patterns) + * [Read the documentation for `P.optional` on GitHub](https://github.com/gvergnaud/ts-pattern#poptional-patterns) * * @example * match(value) @@ -217,7 +217,7 @@ export type Chainable = p & * `pattern.and(pattern)` returns a pattern that matches * if the previous pattern and the next one match the input. * - * [Read the documentation for `P.intersection` on GitHub](https://github.com/gvergnaud/ts-pattern#Pintersection-patterns) + * [Read the documentation for `P.intersection` on GitHub](https://github.com/gvergnaud/ts-pattern#pintersection-patterns) * * @example * match(value) @@ -233,7 +233,7 @@ export type Chainable = p & * `pattern.or(pattern)` returns a pattern that matches * if **either** the previous pattern or the next one match the input. * - * [Read the documentation for `P.union` on GitHub](https://github.com/gvergnaud/ts-pattern#Punion-patterns) + * [Read the documentation for `P.union` on GitHub](https://github.com/gvergnaud/ts-pattern#punion-patterns) * * @example * match(value) @@ -248,7 +248,7 @@ export type Chainable = p & /** * `P.select()` will inject this property into the handler function's arguments. * - * [Read the documentation for `P.select` on GitHub](https://github.com/gvergnaud/ts-pattern#Pselect-patterns) + * [Read the documentation for `P.select` on GitHub](https://github.com/gvergnaud/ts-pattern#pselect-patterns) * * @example * match<{ age: number }>(value) @@ -274,7 +274,7 @@ export type StringChainable< /** * `P.string.startsWith(start)` is a pattern, matching **strings** starting with `start`. * - * [Read the documentation for `P.string.startsWith` on GitHub](https://github.com/gvergnaud/ts-pattern#PstringstartsWith) + * [Read the documentation for `P.string.startsWith` on GitHub](https://github.com/gvergnaud/ts-pattern#pstringstartsWith) * * @example * match(value) @@ -289,7 +289,7 @@ export type StringChainable< /** * `P.string.endsWith(end)` is a pattern, matching **strings** ending with `end`. * - * [Read the documentation for `P.string.endsWith` on GitHub](https://github.com/gvergnaud/ts-pattern#PstringendsWith) + * [Read the documentation for `P.string.endsWith` on GitHub](https://github.com/gvergnaud/ts-pattern#pstringendsWith) * * @example * match(value) @@ -304,7 +304,7 @@ export type StringChainable< /** * `P.string.minLength(min)` is a pattern, matching **strings** with at least `min` characters. * - * [Read the documentation for `P.string.minLength` on GitHub](https://github.com/gvergnaud/ts-pattern#PstringminLength) + * [Read the documentation for `P.string.minLength` on GitHub](https://github.com/gvergnaud/ts-pattern#pstringminLength) * * @example * match(value) @@ -319,7 +319,7 @@ export type StringChainable< /** * `P.string.maxLength(max)` is a pattern, matching **strings** with at most `max` characters. * - * [Read the documentation for `P.string.maxLength` on GitHub](https://github.com/gvergnaud/ts-pattern#PstringmaxLength) + * [Read the documentation for `P.string.maxLength` on GitHub](https://github.com/gvergnaud/ts-pattern#pstringmaxLength) * * @example * match(value) @@ -334,7 +334,7 @@ export type StringChainable< /** * `P.string.includes(substr)` is a pattern, matching **strings** containing `substr`. * - * [Read the documentation for `P.string.includes` on GitHub](https://github.com/gvergnaud/ts-pattern#Pstringincludes) + * [Read the documentation for `P.string.includes` on GitHub](https://github.com/gvergnaud/ts-pattern#pstringincludes) * * @example * match(value) @@ -349,7 +349,7 @@ export type StringChainable< /** * `P.string.regex(expr)` is a pattern, matching **strings** that `expr` regular expression. * - * [Read the documentation for `P.string.regex` on GitHub](https://github.com/gvergnaud/ts-pattern#Pstringregex) + * [Read the documentation for `P.string.regex` on GitHub](https://github.com/gvergnaud/ts-pattern#pstringregex) * * @example * match(value) @@ -375,7 +375,7 @@ export type NumberChainable = Chainable< * `P.number.between(min, max)` matches **number** between `min` and `max`, * equal to min or equal to max. * - * [Read the documentation for `P.number.between` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberbetween) + * [Read the documentation for `P.number.between` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberbetween) * * @example * match(value) @@ -391,7 +391,7 @@ export type NumberChainable = Chainable< /** * `P.number.lt(max)` matches **number** smaller than `max`. * - * [Read the documentation for `P.number.lt` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberlt) + * [Read the documentation for `P.number.lt` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberlt) * * @example * match(value) @@ -406,7 +406,7 @@ export type NumberChainable = Chainable< /** * `P.number.gt(min)` matches **number** greater than `min`. * - * [Read the documentation for `P.number.gt` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumbergt) + * [Read the documentation for `P.number.gt` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumbergt) * * @example * match(value) @@ -421,7 +421,7 @@ export type NumberChainable = Chainable< /** * `P.number.lte(max)` matches **number** smaller than or equal to `max`. * - * [Read the documentation for `P.number.lte` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberlte) + * [Read the documentation for `P.number.lte` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberlte) * * @example * match(value) @@ -436,7 +436,7 @@ export type NumberChainable = Chainable< /** * `P.number.gte(min)` matches **number** greater than or equal to `min`. * - * [Read the documentation for `P.number.gte` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumbergte) + * [Read the documentation for `P.number.gte` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumbergte) * * @example * match(value) @@ -451,7 +451,7 @@ export type NumberChainable = Chainable< /** * `P.number.int` matches **integer** numbers. * - * [Read the documentation for `P.number.int` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberint) + * [Read the documentation for `P.number.int` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberint) * * @example * match(value) @@ -464,7 +464,7 @@ export type NumberChainable = Chainable< /** * `P.number.finite` matches **finite numbers**. * - * [Read the documentation for `P.number.finite` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberfinite) + * [Read the documentation for `P.number.finite` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberfinite) * * @example * match(value) @@ -477,7 +477,7 @@ export type NumberChainable = Chainable< /** * `P.number.positive` matches **positive** numbers. * - * [Read the documentation for `P.number.positive` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberpositive) + * [Read the documentation for `P.number.positive` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberpositive) * * @example * match(value) @@ -490,7 +490,7 @@ export type NumberChainable = Chainable< /** * `P.number.negative` matches **negative** numbers. * - * [Read the documentation for `P.number.negative` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumbernegative) + * [Read the documentation for `P.number.negative` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumbernegative) * * @example * match(value) @@ -514,7 +514,7 @@ export type BigIntChainable = Chainable< * `P.bigint.between(min, max)` matches **bigint** between `min` and `max`, * equal to min or equal to max. * - * [Read the documentation for `P.bigint.between` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberbetween) + * [Read the documentation for `P.bigint.between` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberbetween) * * @example * match(value) @@ -530,7 +530,7 @@ export type BigIntChainable = Chainable< /** * `P.bigint.lt(max)` matches **bigint** smaller than `max`. * - * [Read the documentation for `P.bigint.lt` on GitHub](https://github.com/gvergnaud/ts-pattern#bigintlt) + * [Read the documentation for `P.bigint.lt` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberlt) * * @example * match(value) @@ -545,7 +545,7 @@ export type BigIntChainable = Chainable< /** * `P.bigint.gt(min)` matches **bigint** greater than `min`. * - * [Read the documentation for `P.bigint.gt` on GitHub](https://github.com/gvergnaud/ts-pattern#bigintgt) + * [Read the documentation for `P.bigint.gt` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumbergt) * * @example * match(value) @@ -560,7 +560,7 @@ export type BigIntChainable = Chainable< /** * `P.bigint.lte(max)` matches **bigint** smaller than or equal to `max`. * - * [Read the documentation for `P.bigint.lte` on GitHub](https://github.com/gvergnaud/ts-pattern#bigintlte) + * [Read the documentation for `P.bigint.lte` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberlte) * * @example * match(value) @@ -575,7 +575,7 @@ export type BigIntChainable = Chainable< /** * `P.bigint.gte(min)` matches **bigint** greater than or equal to `min`. * - * [Read the documentation for `P.bigint.gte` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumbergte) + * [Read the documentation for `P.bigint.gte` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumbergte) * * @example * match(value) @@ -590,7 +590,7 @@ export type BigIntChainable = Chainable< /** * `P.bigint.positive` matches **positive** bigints. * - * [Read the documentation for `P.bigint.positive` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberpositive) + * [Read the documentation for `P.bigint.positive` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumberpositive) * * @example * match(value) @@ -603,7 +603,7 @@ export type BigIntChainable = Chainable< /** * `P.bigint.negative` matches **negative** bigints. * - * [Read the documentation for `P.bigint.negative` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumbernegative) + * [Read the documentation for `P.bigint.negative` on GitHub](https://github.com/gvergnaud/ts-pattern#pnumbernegative) * * @example * match(value) @@ -629,7 +629,7 @@ export type ArrayChainable< * `.optional()` returns a pattern which matches if the * key is undefined or if it is defined and the previous pattern matches its value. * - * [Read the documentation for `P.optional` on GitHub](https://github.com/gvergnaud/ts-pattern#Poptional-patterns) + * [Read the documentation for `P.optional` on GitHub](https://github.com/gvergnaud/ts-pattern#poptional-patterns) * * @example * match(value) @@ -642,7 +642,7 @@ export type ArrayChainable< /** * `P.select()` will inject this property into the handler function's arguments. * - * [Read the documentation for `P.select` on GitHub](https://github.com/gvergnaud/ts-pattern#Pselect-patterns) + * [Read the documentation for `P.select` on GitHub](https://github.com/gvergnaud/ts-pattern#pselect-patterns) * * @example * match<{ age: number }>(value)