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

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

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

Returns false if the given string does not contain the given Middle type, or a 3-tuple containing the start, the matched middle, and the rest.

Examples

Example 1

SplitAt<'abcd', 'bc'> => ['a', 'bc', 'd']
SplitAt<'abcd', 'ef'> => false
SplitAt<'abcd', 'b' | 'c'> => ['a', 'b', 'cd'] | ['ab', 'c', 'd']

Type Parameters

S extends string
Middle extends string & NonEmptyString<Middle>
definition: S extends AppendTwo<infer Start, Middle, infer End> ? S extends AppendTwo<Start, infer MiddleInstance, End> ? [Start, MiddleInstance, End] : false : ["", "", S]