MCPcopy
hub / github.com/gvergnaud/ts-pattern / f

Function f

tests/bigints.test.ts:6–15  ·  view source on GitHub ↗
(input: string | bigint)

Source from the content-addressed store, hash-verified

4describe('BigInts', () => {
5 it(`P.bigint.between(1, 10)`, () => {
6 const f = (input: string | bigint) =>
7 match(input)
8 .with(P.bigint.between(0n, 10n), (value) => {
9 type t = Expect<Equal<typeof value, bigint>>;
10 return 'between 0 and 10';
11 })
12 .otherwise((value) => {
13 type t = Expect<Equal<typeof value, string | bigint>>;
14 return 'something else';
15 });
16
17 expect(f(5n)).toBe('between 0 and 10');
18 expect(f(0n)).toBe('between 0 and 10');

Callers 1

bigints.test.tsFile · 0.70

Calls 3

matchFunction · 0.90
otherwiseMethod · 0.80
withMethod · 0.80

Tested by

no test coverage detected