Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/rimbu/typical/str.ts>Contains

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

Returns true if the given string contains the given Amount (default 1) of Sub types.

Examples

Example 1

Contains<'abcba', 'b'> => true
Contains<'abcba', 'b', 2> => true
Contains<'abcba', 'b', 3> => false
Contains<'abcba', 'q'> => false

Type Parameters

S extends string
Sub extends string & NonEmptyString<Sub>
optional
Amount extends number = 1
definition: Amount extends 0 ? true : S extends Append<Sub, infer Rest> ? Contains<Rest, Sub, Num.Decr<Amount>> : S extends Append<string, infer Rest> ? Contains<Rest, Sub, Amount> : false