MCPcopy Index your code
hub / github.com/Effect-TS/effect / discriminatorStartsWith

Function discriminatorStartsWith

packages/effect/src/internal/matcher.ts:370–395  ·  view source on GitHub ↗
(field: D)

Source from the content-addressed store, hash-verified

368
369/** @internal */
370export const discriminatorStartsWith = <D extends string>(field: D) =>
371<
372 R,
373 P extends string,
374 Ret,
375 Fn extends (_: Extract<R, Record<D, `${P}${string}`>>) => Ret
376>(
377 pattern: P,
378 f: Fn
379) => {
380 const pred = (_: any) => _ != null && typeof _[field] === "string" && _[field].startsWith(pattern)
381
382 return <I, F, A, Pr>(
383 self: Matcher<I, F, R, A, Pr, Ret>
384 ): Matcher<
385 I,
386 Types.AddWithout<F, Extract<R, Record<D, `${P}${string}`>>>,
387 Types.ApplyFilters<
388 I,
389 Types.AddWithout<F, Extract<R, Record<D, `${P}${string}`>>>
390 >,
391 A | ReturnType<Fn>,
392 Pr,
393 Ret
394 > => (self as any).add(makeWhen(pred, f as any)) as any
395}
396
397/** @internal */
398export const discriminators = <D extends string>(field: D) =>

Callers 1

matcher.tsFile · 0.85

Calls 2

makeWhenFunction · 0.85
addMethod · 0.65

Tested by

no test coverage detected