Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/rimbu/typical/mod.ts>Str.Contains

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

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