Skip to main content
Module

x/rimbu/typical/mod.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@0.13.1/typical/mod.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]