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

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

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

Returns a tuple containing the matched part and the rest of the given string if the string start repeats the given Sub at least N times.

Examples

Example 1

RepeatAtLeastTimes<'aabc', 'a', 0> => ['', 'aabc']
RepeatAtLeastTimes<'aabc', 'a', 1> => ['a', 'abc']
RepeatAtLeastTimes<'aabc', 'a', 3> => false
RepeatAtLeastTimes<'aabc', 'a' | 'b', 3> => ['aab', 'c']

Type Parameters

S extends string
Sub extends string & NonEmptyString<Sub>
N extends number
definition: RepeatAtLeastTimesHelper<S, Sub, N, "">