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

Function containsGabAndYo

tests/sets.test.ts:6–24  ·  view source on GitHub ↗
(set: Set<string | number>)

Source from the content-addressed store, hash-verified

4describe('Set', () => {
5 it('should match Set patterns', () => {
6 const containsGabAndYo = (set: Set<string | number>) =>
7 match<Set<string | number>, [boolean, boolean]>(set)
8 .with(P.set('gab'), (x) => {
9 type t = Expect<Equal<typeof x, Set<'gab'>>>;
10 return [true, false];
11 })
12 .with(P.set('yo'), (x) => {
13 type t = Expect<Equal<typeof x, Set<'yo'>>>;
14 return [false, true];
15 })
16 .with(P.set(P.union('gab', 'yo')), (x) => {
17 type t = Expect<Equal<typeof x, Set<'gab' | 'yo'>>>;
18 return [true, true];
19 })
20 .with(P._, (x) => {
21 type t = Expect<Equal<typeof x, Set<string | number>>>;
22 return [false, false];
23 })
24 .run();
25
26 expect(containsGabAndYo(new Set(['gab', 'yo']))).toEqual([true, true]);
27 expect(containsGabAndYo(new Set(['gab']))).toEqual([true, false]);

Callers 1

sets.test.tsFile · 0.85

Calls 3

matchFunction · 0.90
runMethod · 0.80
withMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…