MCPcopy Create free account
hub / github.com/gvergnaud/ts-pattern / stringChainable

Function stringChainable

src/patterns.ts:900–917  ·  view source on GitHub ↗
(
  pattern: pattern
)

Source from the content-addressed store, hash-verified

898 when((value) => isString(value) && Boolean(value.match(expr)));
899
900const stringChainable = <pattern extends Matcher<any, any, any, any, any>>(
901 pattern: pattern
902): StringChainable<pattern> =>
903 Object.assign(chainable(pattern), {
904 startsWith: (str: string) =>
905 stringChainable(intersection(pattern, startsWith(str))),
906 endsWith: (str: string) =>
907 stringChainable(intersection(pattern, endsWith(str))),
908 minLength: (min: number) =>
909 stringChainable(intersection(pattern, minLength(min))),
910 length: (len: number) =>
911 stringChainable(intersection(pattern, length(len))),
912 maxLength: (max: number) =>
913 stringChainable(intersection(pattern, maxLength(max))),
914 includes: (str: string) =>
915 stringChainable(intersection(pattern, includes(str))),
916 regex: (str: string) => stringChainable(intersection(pattern, regex(str))),
917 }) as any;
918
919/**
920 * `P.string` is a wildcard pattern, matching any **string**.

Callers 1

patterns.tsFile · 0.85

Calls 9

chainableFunction · 0.85
intersectionFunction · 0.85
endsWithFunction · 0.85
minLengthFunction · 0.85
lengthFunction · 0.85
maxLengthFunction · 0.85
includesFunction · 0.85
startsWithFunction · 0.70
regexFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…