Skip to main content
Module

x/rimbu/typical/mod.ts>Str.EndsWith

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Latest
type alias Str.EndsWith
import { type Str } from "https://deno.land/x/rimbu@1.2.1/typical/mod.ts";
const { EndsWith } = Str;

If the given string does not end with the given End type, returns false. Otherwise, returns a tuple containing the start and the matched end.

Examples

Example 1

EndsWith<'abcd', 'cd'> => ['ab', 'cd']
EndsWith<'abcd', 'a'> => false
EndsWith<'abcd', 'cd' | 'de'> => ['ab', 'cd']
EndsWith<'abcd', 'cd' | 'd'> => ['ab', 'cd'] | ['abc', 'd']

Type Parameters

S extends string
End extends string & NonEmptyString<End>
definition: S extends Append<infer Start, End> ? S extends Append<Start, infer EndInstance> ? [Start, EndInstance] : false : false