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

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

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

Type Parameters

Tp extends RMapBase.Types
optional
UK = unknown

Methods

empty<K extends UK, V>(): WithKeyValue<Tp, K, V>["normal"]

Returns the (singleton) empty instance of this type and context with given key and value types.

of<K extends UK, V>(...entries: ArrayNonEmpty<readonly [K, V]>): WithKeyValue<Tp, K, V>["nonEmpty"]

Returns an immutable map of this collection type and context, containing the given entries.

from<K extends UK, V>(...sources: ArrayNonEmpty<StreamSource.NonEmpty<readonly [K, V]>>): WithKeyValue<Tp, K, V>["nonEmpty"]

Returns an immutable map of this type and context, containing the entries in the given sources StreamSource instances.

from<K, V>(...sources: ArrayNonEmpty<StreamSource<readonly [K, V]>>): WithKeyValue<Tp, K, V>["normal"]
builder<K extends UK, V>(): WithKeyValue<Tp, K, V>["builder"]

Returns an empty builder instance for this type of collection and context.

reducer<K extends UK, V>(source?: StreamSource<readonly [K, V]>): Reducer<readonly [K, V], WithKeyValue<Tp, K, V>["normal"]>

Returns a Reducer that adds received tuples to an RMap and returns the RMap as a result. When a source is given, the reducer will first create an RMap from the source, and then add tuples to it.

mergeAll<O, I extends readonly [unknown, unknown, ...unknown[]], K extends UK>(fillValue: O, ...sources: [KT in keyof I]: StreamSource.NonEmpty<readonly [K, I[KT]]> & unknown[]): WithKeyValue<Tp, K, [KT in keyof I]: I[KT] | O>["nonEmpty"]

Returns a Map containing all keys from this map and all the given sources key-value stream sources, and as values tuples of all the corresponding values for each key. If a source doesn't have a key, the tuple will be filled with the given fillValue.

mergeAll<O, I extends readonly [unknown, unknown, ...unknown[]], K extends UK>(fillValue: O, ...sources: [KT in keyof I]: StreamSource<readonly [K, I[KT]]> & unknown[]): WithKeyValue<Tp, K, [KT in keyof I]: I[KT] | O>["normal"]
mergeAllWith<I extends readonly [unknown, unknown, ...unknown[]], K extends UK>(...sources: [KT in keyof I]: StreamSource.NonEmpty<readonly [K, I[KT]]> & unknown[]): <O, R>(fillValue: O, mergeFun: (key: K, ...values: [KT in keyof I]: I[KT] | O) => R) => WithKeyValue<Tp, K, R>["nonEmpty"]

Returns a Map containing all keys from this map and all the given sources key-value stream sources, and as values the result of applying the given mergeFun to the key and all the corresponding values for each key. If a source doesn't have a key, the given tuple will be filled with the given fillValue.

mergeAllWith<I extends readonly [unknown, unknown, ...unknown[]], K extends UK>(...sources: [KT in keyof I]: StreamSource<readonly [K, I[KT]]> & unknown[]): <O, R>(fillValue: O, mergeFun: (key: K, ...values: [KT in keyof I]: I[KT] | O) => R) => WithKeyValue<Tp, K, R>["normal"]
merge<K extends UK, I extends readonly [unknown, unknown, ...unknown[]]>(...sources: [KT in keyof I]: StreamSource.NonEmpty<readonly [K, I[KT]]> & unknown[]): WithKeyValue<Tp, K, [KT in keyof I]: I[KT]>["nonEmpty"]

Returns a Map containing the common keys from this map and all the given sources key-value stream sources, and as values tuples of all the corresponding values for each common key. If a source doesn't have a key, the key will be skipped.

merge<K extends UK, I extends readonly [unknown, unknown, ...unknown[]]>(...sources: [KT in keyof I]: StreamSource<readonly [K, I[KT]]> & unknown[]): WithKeyValue<Tp, K, [KT in keyof I]: I[KT]>["normal"]
mergeWith<I extends readonly [unknown, unknown, ...unknown[]], K extends UK>(...sources: [KT in keyof I]: StreamSource.NonEmpty<readonly [K, I[KT]]> & unknown[]): <R>(mergeFun: (key: K, ...values: I) => R) => WithKeyValue<Tp, K, R>["nonEmpty"]

Returns a Map containing the common keys from this map and all the given sources key-value stream sources, and as values the result of applying given mergeFun to the key and values of all the corresponding values for each common key. If a source doesn't have a key, the key will be skipped.

mergeWith<I extends readonly [unknown, unknown, ...unknown[]], K extends UK>(...sources: [KT in keyof I]: StreamSource<readonly [K, I[KT]]> & unknown[]): <R>(mergeFun: (key: K, ...values: I) => R) => WithKeyValue<Tp, K, R>["normal"]