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

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

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

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

Examples

Example 1

StartsWith<'abcd', 'ab'> => ['ab', 'cd']
StartsWith<'abcd', 'd'> => false
StartsWith<'abcd', 'ab' | 'bc'> => ['ab', 'cd']
StartsWith<'abcd', 'ab' | 'a'> => ['ab', 'cd'] | ['a', 'bcd']

Type Parameters

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