Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

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

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
type alias Str.EndsWith
import { type Str } from "https://deno.land/x/rimbu@0.13.5/typical/index.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