Socket
Socket
Sign inDemoInstall

ts-pattern

Package Overview
Dependencies
Maintainers
1
Versions
151
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 5.0.3-rc.0 to 5.0.3-rc.1

290

dist/patterns.d.ts

@@ -6,3 +6,3 @@ import * as symbols from './internals/symbols.js';

import { InvertPattern } from './types/InvertPattern.js';
import { Pattern, UnknownPattern, OptionalP, ArrayP, MapP, SetP, AndP, OrP, NotP, GuardP, SelectP, AnonymousSelectP, GuardExcludeP, CustomP, Matcher } from './types/Pattern.js';
import { Pattern, UnknownPattern, OptionalP, ArrayP, MapP, SetP, AndP, OrP, NotP, GuardP, SelectP, AnonymousSelectP, GuardExcludeP, CustomP, StringPattern, AnyPattern, NumberPattern, BooleanPattern, BigIntPattern, NullishPattern, SymbolPattern, Chainable } from './types/Pattern.js';
export { Pattern, Fn as unstable_Fn };

@@ -53,54 +53,2 @@ export { matcher };

export type narrow<i, p extends Pattern<any>> = ExtractPreciseValue<i, InvertPattern<p, i>>;
type Chainable<p, omitted extends string = never> = p & Omit<{
/**
* `.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)
*
* @example
* match(value)
* .with({ greeting: P.string.optional() }, () => 'will match { greeting?: string}')
*/
optional<input>(): Chainable<OptionalP<input, p>, omitted | 'optional'>;
/**
* `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)
*
* @example
* match(value)
* .with(
* P.string.and(P.when(isUsername)),
* (username) => '...'
* )
*/
and<input, p2 extends Pattern<input>>(pattern: p2): Chainable<AndP<input, [p, p2]>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(
* { value: P.string.or(P.number) },
* ({ value }) => 'value: number | string'
* )
*/
or<input, p2 extends Pattern<input>>(pattern: p2): Chainable<OrP<input, [p, p2]>, omitted>;
/**
* `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)
*
* @example
* match<{ age: number }>(value)
* .with({ age: P.string.select() }, (age) => 'age: number')
*/
select<input>(): Chainable<SelectP<symbols.anonymousSelectKey, input, p>, omitted | 'select' | 'or' | 'and'>;
select<input, k extends string>(key: k): Chainable<SelectP<k, input, p>, omitted | 'select' | 'or' | 'and'>;
}, omitted>;
type Variadic<p> = p & Iterable<p>;

@@ -257,9 +205,2 @@ type ArrayChainable<p, omitted extends string = never> = Variadic<p> & Omit<{

type AnyConstructor = abstract new (...args: any[]) => any;
export type AnyPattern = Chainable<GuardP<unknown, unknown>, never>;
export type StringPattern = StringChainable<GuardP<unknown, string>, never>;
export type NumberPattern = NumberChainable<GuardP<unknown, number>, never>;
export type BooleanPattern = Chainable<GuardP<unknown, boolean>, never>;
export type BigIntPattern = BigIntChainable<GuardP<unknown, bigint>, never>;
export type SymbolPattern = Chainable<GuardP<unknown, symbol>, never>;
export type NullishPattern = Chainable<GuardP<unknown, null | undefined>, never>;
/**

@@ -286,65 +227,2 @@ * `P.any` is a wildcard pattern, matching **any value**.

export declare const _: AnyPattern;
type MaybeAnd<omitted, input, p1, p2> = [omitted] extends [never] ? p2 : AndP<input, [p1, p2]>;
type StringChainable<p extends Matcher<any, any, any, any, any>, omitted extends string = never> = Chainable<p, omitted> & Omit<{
/**
* `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)
*
* @example
* match(value)
* .with(P.string.startsWith('A'), () => 'value starts with an A')
*/
startsWith<input, const start extends string>(start: start): StringChainable<MaybeAnd<omitted, input, p, GuardP<input, `${start}${string}`>>, omitted | '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)
*
* @example
* match(value)
* .with(P.string.endsWith('!'), () => 'value ends with an !')
*/
endsWith<input, const end extends string>(end: end): StringChainable<MaybeAnd<omitted, input, p, GuardP<input, `${string}${end}`>>, omitted | '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)
*
* @example
* match(value)
* .with(P.string.minLength(10), () => 'string with more length <= 10')
*/
minLength<input, const min extends number>(min: min): StringChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, string, never>>, omitted | 'minLength'>;
/**
* `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)
*
* @example
* match(value)
* .with(P.string.maxLength(10), () => 'string with more length >= 10')
*/
maxLength<input, const max extends number>(max: max): StringChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, string, never>>, omitted | 'maxLength'>;
/**
* `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)
*
* @example
* match(value)
* .with(P.string.includes('http'), () => 'value contains http')
*/
includes<input, const substr extends string>(substr: substr): StringChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, string, never>>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(P.string.regex(/^https?:\/\//), () => 'url')
*/
regex<input, const expr extends string | RegExp>(expr: expr): StringChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, string, never>>, omitted>;
}, omitted>;
/**

@@ -451,95 +329,2 @@ * `P.string` is a wildcard pattern, matching any **string**.

export declare const negative: <input>() => GuardExcludeP<input, number, never>;
type NumberChainable<p, omitted extends string = never> = Chainable<p, omitted> & Omit<{
/**
* `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)
*
* @example
* match(value)
* .with(P.number.between(0, 10), () => '0 <= numbers <= 10')
*/
between<input, const min extends number, const max extends number>(min: min, max: max): NumberChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, number, never>>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(P.number.lt(10), () => 'numbers < 10')
*/
lt<input, const max extends number>(max: max): NumberChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, number, never>>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(P.number.gt(10), () => 'numbers > 10')
*/
gt<input, const min extends number>(min: min): NumberChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, number, never>>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(P.number.lte(10), () => 'numbers <= 10')
*/
lte<input, const max extends number>(max: max): NumberChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, number, never>>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(P.number.gte(10), () => 'numbers >= 10')
*/
gte<input, const min extends number>(min: min): NumberChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, number, never>>, omitted>;
/**
* `P.number.int` matches **integer** numbers.
*
* [Read the documentation for `P.number.int` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberint)
*
* @example
* match(value)
* .with(P.number.int, () => 'an integer')
*/
int<input>(): NumberChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, number, never>>, omitted | 'int'>;
/**
* `P.number.finite` matches **finite numbers**.
*
* [Read the documentation for `P.number.finite` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberfinite)
*
* @example
* match(value)
* .with(P.number.finite, () => 'not Infinity')
*/
finite<input>(): NumberChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, number, never>>, omitted | 'finite'>;
/**
* `P.number.positive` matches **positive** numbers.
*
* [Read the documentation for `P.number.positive` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberpositive)
*
* @example
* match(value)
* .with(P.number.positive, () => 'number > 0')
*/
positive<input>(): NumberChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, number, never>>, omitted | 'positive' | 'negative'>;
/**
* `P.number.negative` matches **negative** numbers.
*
* [Read the documentation for `P.number.negative` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumbernegative)
*
* @example
* match(value)
* .with(P.number.negative, () => 'number < 0')
*/
negative<input>(): NumberChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, number, never>>, omitted | 'positive' | 'negative' | 'negative'>;
}, omitted>;
/**

@@ -626,75 +411,2 @@ * `P.number` is a wildcard pattern, matching any **number**.

export declare const negativeBigInt: <input>() => GuardExcludeP<input, bigint, never>;
type BigIntChainable<p, omitted extends string = never> = Chainable<p, omitted> & Omit<{
/**
* `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)
*
* @example
* match(value)
* .with(P.bigint.between(0, 10), () => '0 <= numbers <= 10')
*/
between<input, const min extends bigint, const max extends bigint>(min: min, max: max): BigIntChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, bigint, never>>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(P.bigint.lt(10), () => 'numbers < 10')
*/
lt<input, const max extends bigint>(max: max): BigIntChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, bigint, never>>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(P.bigint.gt(10), () => 'numbers > 10')
*/
gt<input, const min extends bigint>(min: min): BigIntChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, bigint, never>>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(P.bigint.lte(10), () => 'bigints <= 10')
*/
lte<input, const max extends bigint>(max: max): BigIntChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, bigint, never>>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(P.bigint.gte(10), () => 'bigints >= 10')
*/
gte<input, const min extends bigint>(min: min): BigIntChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, bigint, never>>, omitted>;
/**
* `P.bigint.positive` matches **positive** bigints.
*
* [Read the documentation for `P.bigint.positive` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberpositive)
*
* @example
* match(value)
* .with(P.bigint.positive, () => 'bigint > 0')
*/
positive<input>(): BigIntChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, bigint, never>>, omitted | 'positive' | 'negative'>;
/**
* `P.bigint.negative` matches **negative** bigints.
*
* [Read the documentation for `P.bigint.negative` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumbernegative)
*
* @example
* match(value)
* .with(P.bigint.negative, () => 'bigint < 0')
*/
negative<input>(): BigIntChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, bigint, never>>, omitted | 'positive' | 'negative' | 'negative'>;
}, omitted>;
/**

@@ -701,0 +413,0 @@ * `P.bigint` is a wildcard pattern, matching any **bigint**.

288

dist/types/Pattern.d.ts

@@ -69,2 +69,290 @@ import type * as symbols from '../internals/symbols.js';

} : readonly [] | readonly [Pattern<i>, ...Pattern<i>[]] | readonly [...Pattern<i>[], Pattern<i>] : never;
export type AnyPattern = Chainable<GuardP<unknown, unknown>, never>;
export type StringPattern = StringChainable<GuardP<unknown, string>, never>;
export type NumberPattern = NumberChainable<GuardP<unknown, number>, never>;
export type BooleanPattern = Chainable<GuardP<unknown, boolean>, never>;
export type BigIntPattern = BigIntChainable<GuardP<unknown, bigint>, never>;
export type SymbolPattern = Chainable<GuardP<unknown, symbol>, never>;
export type NullishPattern = Chainable<GuardP<unknown, null | undefined>, never>;
type MaybeAnd<omitted, input, p1, p2> = [omitted] extends [never] ? p2 : AndP<input, [p1, p2]>;
export type Chainable<p, omitted extends string = never> = p & Omit<{
/**
* `.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)
*
* @example
* match(value)
* .with({ greeting: P.string.optional() }, () => 'will match { greeting?: string}')
*/
optional<input>(): Chainable<OptionalP<input, p>, omitted | 'optional'>;
/**
* `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)
*
* @example
* match(value)
* .with(
* P.string.and(P.when(isUsername)),
* (username) => '...'
* )
*/
and<input, p2 extends Pattern<input>>(pattern: p2): Chainable<AndP<input, [p, p2]>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(
* { value: P.string.or(P.number) },
* ({ value }) => 'value: number | string'
* )
*/
or<input, p2 extends Pattern<input>>(pattern: p2): Chainable<OrP<input, [p, p2]>, omitted>;
/**
* `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)
*
* @example
* match<{ age: number }>(value)
* .with({ age: P.string.select() }, (age) => 'age: number')
*/
select<input>(): Chainable<SelectP<symbols.anonymousSelectKey, input, p>, omitted | 'select' | 'or' | 'and'>;
select<input, k extends string>(key: k): Chainable<SelectP<k, input, p>, omitted | 'select' | 'or' | 'and'>;
}, omitted>;
export type StringChainable<p extends Matcher<any, any, any, any, any>, omitted extends string = never> = Chainable<p, omitted> & Omit<{
/**
* `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)
*
* @example
* match(value)
* .with(P.string.startsWith('A'), () => 'value starts with an A')
*/
startsWith<input, const start extends string>(start: start): StringChainable<MaybeAnd<omitted, input, p, GuardP<input, `${start}${string}`>>, omitted | '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)
*
* @example
* match(value)
* .with(P.string.endsWith('!'), () => 'value ends with an !')
*/
endsWith<input, const end extends string>(end: end): StringChainable<MaybeAnd<omitted, input, p, GuardP<input, `${string}${end}`>>, omitted | '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)
*
* @example
* match(value)
* .with(P.string.minLength(10), () => 'string with more length <= 10')
*/
minLength<input, const min extends number>(min: min): StringChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, string, never>>, omitted | 'minLength'>;
/**
* `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)
*
* @example
* match(value)
* .with(P.string.maxLength(10), () => 'string with more length >= 10')
*/
maxLength<input, const max extends number>(max: max): StringChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, string, never>>, omitted | 'maxLength'>;
/**
* `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)
*
* @example
* match(value)
* .with(P.string.includes('http'), () => 'value contains http')
*/
includes<input, const substr extends string>(substr: substr): StringChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, string, never>>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(P.string.regex(/^https?:\/\//), () => 'url')
*/
regex<input, const expr extends string | RegExp>(expr: expr): StringChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, string, never>>, omitted>;
}, omitted>;
export type NumberChainable<p, omitted extends string = never> = Chainable<p, omitted> & Omit<{
/**
* `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)
*
* @example
* match(value)
* .with(P.number.between(0, 10), () => '0 <= numbers <= 10')
*/
between<input, const min extends number, const max extends number>(min: min, max: max): NumberChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, number, never>>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(P.number.lt(10), () => 'numbers < 10')
*/
lt<input, const max extends number>(max: max): NumberChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, number, never>>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(P.number.gt(10), () => 'numbers > 10')
*/
gt<input, const min extends number>(min: min): NumberChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, number, never>>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(P.number.lte(10), () => 'numbers <= 10')
*/
lte<input, const max extends number>(max: max): NumberChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, number, never>>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(P.number.gte(10), () => 'numbers >= 10')
*/
gte<input, const min extends number>(min: min): NumberChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, number, never>>, omitted>;
/**
* `P.number.int` matches **integer** numbers.
*
* [Read the documentation for `P.number.int` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberint)
*
* @example
* match(value)
* .with(P.number.int, () => 'an integer')
*/
int<input>(): NumberChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, number, never>>, omitted | 'int'>;
/**
* `P.number.finite` matches **finite numbers**.
*
* [Read the documentation for `P.number.finite` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberfinite)
*
* @example
* match(value)
* .with(P.number.finite, () => 'not Infinity')
*/
finite<input>(): NumberChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, number, never>>, omitted | 'finite'>;
/**
* `P.number.positive` matches **positive** numbers.
*
* [Read the documentation for `P.number.positive` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberpositive)
*
* @example
* match(value)
* .with(P.number.positive, () => 'number > 0')
*/
positive<input>(): NumberChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, number, never>>, omitted | 'positive' | 'negative'>;
/**
* `P.number.negative` matches **negative** numbers.
*
* [Read the documentation for `P.number.negative` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumbernegative)
*
* @example
* match(value)
* .with(P.number.negative, () => 'number < 0')
*/
negative<input>(): NumberChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, number, never>>, omitted | 'positive' | 'negative' | 'negative'>;
}, omitted>;
export type BigIntChainable<p, omitted extends string = never> = Chainable<p, omitted> & Omit<{
/**
* `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)
*
* @example
* match(value)
* .with(P.bigint.between(0, 10), () => '0 <= numbers <= 10')
*/
between<input, const min extends bigint, const max extends bigint>(min: min, max: max): BigIntChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, bigint, never>>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(P.bigint.lt(10), () => 'numbers < 10')
*/
lt<input, const max extends bigint>(max: max): BigIntChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, bigint, never>>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(P.bigint.gt(10), () => 'numbers > 10')
*/
gt<input, const min extends bigint>(min: min): BigIntChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, bigint, never>>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(P.bigint.lte(10), () => 'bigints <= 10')
*/
lte<input, const max extends bigint>(max: max): BigIntChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, bigint, never>>, omitted>;
/**
* `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)
*
* @example
* match(value)
* .with(P.bigint.gte(10), () => 'bigints >= 10')
*/
gte<input, const min extends bigint>(min: min): BigIntChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, bigint, never>>, omitted>;
/**
* `P.bigint.positive` matches **positive** bigints.
*
* [Read the documentation for `P.bigint.positive` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumberpositive)
*
* @example
* match(value)
* .with(P.bigint.positive, () => 'bigint > 0')
*/
positive<input>(): BigIntChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, bigint, never>>, omitted | 'positive' | 'negative'>;
/**
* `P.bigint.negative` matches **negative** bigints.
*
* [Read the documentation for `P.bigint.negative` on GitHub](https://github.com/gvergnaud/ts-pattern#Pnumbernegative)
*
* @example
* match(value)
* .with(P.bigint.negative, () => 'bigint < 0')
*/
negative<input>(): BigIntChainable<MaybeAnd<omitted, input, p, GuardExcludeP<input, bigint, never>>, omitted | 'positive' | 'negative' | 'negative'>;
}, omitted>;
export {};
{
"name": "ts-pattern",
"version": "5.0.3-rc.0",
"version": "5.0.3-rc.1",
"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

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