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

x/rimbu/collection-types/map-custom/index.ts>RMapBase.Builder

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
interface RMapBase.Builder
import { type RMapBase } from "https://deno.land/x/rimbu@0.13.0/collection-types/map-custom/index.ts";
const { Builder } = RMapBase;

Properties

readonly
context: WithKeyValue<Tp, K, V>["context"]

Returns the context associated to this collection instance.

readonly
size: number

Returns the amount of entries in the builder.

readonly
isEmpty: boolean

Returns true if there are no entries in the builder.

Methods

get<UK = K>(key: RelatedTo<K, UK>): V | undefined

Returns the value associated with the given key, or given otherwise value if the key is not in the collection.

get<UK, O>(key: RelatedTo<K, UK>, otherwise: OptLazy<O>): V | O
hasKey<UK = K>(key: RelatedTo<K, UK>): boolean

Returns true if the given key is present in the builder.

forEach(f: (
entry: readonly [K, V],
index: number,
halt: () => void,
) => void
, state?: TraverseState
): void

Performs given function f for each entry of the builder.

addEntry(entry: readonly [K, V]): boolean

Adds given entry to the builder.

addEntries(entries: StreamSource<readonly [K, V]>): boolean

Adds given entries to the builder.

set(key: K, value: V): boolean

Associates given key with given value in the builder.

removeKey<UK = K>(key: RelatedTo<K, UK>): V | undefined

Removes the entry with given key from the builder.

removeKey<UK, O>(key: RelatedTo<K, UK>, otherwise: OptLazy<O>): V | O
removeKeys<UK = K>(keys: StreamSource<RelatedTo<K, UK>>): boolean

Removes the entries in the given keys StreamSource from the builder.

modifyAt(key: K, options: { ifNew?: OptLazyOr<V, Token>; ifExists?: <V2 extends V = V>(currentValue: V & V2, remove: Token) => V | Token; }): boolean

Modifies or creates the builder entry with given atKey as its key according to given options.

updateAt(key: K, update: RMapBase.Update<V>): V | undefined

Updates the value in the builder associated with given key according to given update value or function.

updateAt<O>(
key: K,
update: RMapBase.Update<V>,
otherwise: OptLazy<O>,
): V | O
build(): WithKeyValue<Tp, K, V>["normal"]

Returns an immutable collection instance containing the entries in this builder.

buildMapValues<V2>(mapFun: (value: V, key: K) => V2): (Tp & KeyValue<K, V2>)["normal"]

Returns an immutable instance of the entries in this builder, with given mapValues function applied to all the values in the entries.