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

x/rimbu/collection-types/set-custom/index.ts>VariantSetBase

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
namespace VariantSetBase
import { VariantSetBase } from "https://deno.land/x/rimbu@0.14.0/collection-types/set-custom/index.ts";

Interfaces

Utility interface that provides higher-kinded types for this collection.

interface VariantSetBase
implements FastIterable<T>
import { type VariantSetBase } from "https://deno.land/x/rimbu@0.14.0/collection-types/set-custom/index.ts";

Properties

readonly
size: number

Returns the number of values in the collection.

readonly
isEmpty: boolean

Returns true if the collection is empty.

Methods

nonEmpty(): this is WithElem<Tp, T>["nonEmpty"]

Returns true if there is at least one entry in the collection, and instructs the compiler to treat the collection as a .NonEmpty type.

assumeNonEmpty(): WithElem<Tp, T>["nonEmpty"]

Returns the same collection typed as non-empty.

stream(): Stream<T>

Returns a Stream containing all elements of this collection.

has<U = T>(value: RelatedTo<T, U>): boolean

Returns true if given value is in the collection.

remove<U = T>(value: RelatedTo<T, U>): WithElem<Tp, T>["normal"]

Returns the collection with given value removed.

removeAll<U = T>(values: StreamSource<RelatedTo<T, U>>): WithElem<Tp, T>["normal"]

Returns the collection with all values in the given values StreamSource removed.

forEach(f: (
value: T,
index: number,
halt: () => void,
) => void
, state?: TraverseState
): void

Performs given function f for each value of the collection, using given state as initial traversal state.

filter(pred: (
value: T,
index: number,
halt: () => void,
) => boolean
): WithElem<Tp, T>["normal"]

Returns a collection containing only those entries that satisfy given pred predicate.

difference<U = T>(other: StreamSource<RelatedTo<T, U>>): WithElem<Tp, T>["normal"]

Returns a collection where each value of given other StreamSource is removed from this collection.

intersect<U = T>(other: StreamSource<RelatedTo<T, U>>): WithElem<Tp, T>["normal"]

Returns a collection containing values that are both in this collection, and in the given other StreamSource.

toArray(): T[]

Returns an array containing all values in this collection.

toString(): string

Returns a string representation of this collection.

toJSON(): ToJSON<T[]>

Returns a JSON representation of this collection.