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

Function exhaustive

tests/multiple-patterns.test.ts:180–194  ·  view source on GitHub ↗
(input: Input)

Source from the content-addressed store, hash-verified

178 .run();
179
180 const exhaustive = (input: Input) =>
181 match<Input>(input)
182 .with(null, undefined, (x) => 'Nullable')
183 .with(P.boolean, P.number, P.string, (x) => 'primitive')
184 .with(
185 { a: P.string },
186 [true, 2],
187 P.map(P.string, P._),
188 P.set(P.number),
189 (x) => 'Object'
190 )
191 .with([false, 2], (x) => '[false, 2]')
192 .with([false, P.number], (x) => '[false, number]')
193 .with([true, P.number], (x) => '[true, number]')
194 .exhaustive();
195
196 const cases: { input: Input; expected: string }[] = [
197 { input: null, expected: 'Nullable' },

Callers 1

Calls 3

matchFunction · 0.90
exhaustiveMethod · 0.80
withMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…