Skip to main content

class OrderedMapContextImpl<UK,Tp>

undocumented

Extends: ContextBase<UK,Tp>

Implements: OrderedMapBase.Context<UK,Tp>

Type parameters

NameConstraintsDefaultDescription
UKundocumented
TpOrderedMapTypesOrderedMapTypesundocumented

Properties

_empty

undocumented

Definition

readonly _empty: WithKeyValue<Tp, any, any>['normal'];

Overrides

ContextBase._empty

_fixedKeyType

undocumented

Definition

_fixedKeyType: any;

Overrides

Context._fixedKeyTypeContextBase._fixedKeyType

_types

undocumented

Definition

get _types(): Tp;

Overrides

Context._typesContextBase._types

builder

undocumented

Definition

readonly builder: <K extends UK, V>() => WithKeyValue<Tp, K, V>["builder"];

Overrides

ContextBase.builder

empty

undocumented

Definition

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

Overrides

ContextBase.empty

from

undocumented

Definition

readonly from: any;

Overrides

ContextBase.from

listContext

undocumented

Definition

readonly listContext: List.Context;

Overrides

Context.listContext

mapContext

undocumented

Definition

readonly mapContext: WithKeyValue<Tp, UK, any>['sourceContext'];

Overrides

Context.mapContext

merge

undocumented

Definition

readonly merge: any;

Overrides

ContextBase.merge

mergeAll

undocumented

Definition

readonly mergeAll: any;

Overrides

ContextBase.mergeAll

mergeAllWith

undocumented

Definition

readonly mergeAllWith: any;

Overrides

ContextBase.mergeAllWith

mergeWith

undocumented

Definition

readonly mergeWith: any;

Overrides

ContextBase.mergeWith

of

undocumented

Definition

readonly of: <K extends UK, V>(values_0: readonly [K, V], ...values_1: (readonly [K, V])[]) => K extends UK ? WithKeyValue<Tp, K, V>["nonEmpty"] : never;

Overrides

ContextBase.of

reducer

undocumented

Definition

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

Overrides

ContextBase.reducer

typeTag

undocumented

Definition

readonly typeTag = "OrderedMap";

Overrides

ContextBase.typeTagContext.typeTag

Methods

builder

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

Definition

builder<K extends UK, V>(): WithKeyValue<Tp, K, V>['builder'];

Type parameters

NameConstraintsDescription
KUK
V
example
HashMap.builder<number, string>()    // => HashMap.Builder<number, string>

Overrides

Factory.builder

createBuilder

undocumented

Definition

createBuilder<K extends UK, V>(source?: any): any;

Type parameters

NameConstraintsDescription
KUK
V

Parameters

NameTypeDescription
sourceany

createNonEmpty

undocumented

Definition

createNonEmpty<K extends UK, V>(order: List.NonEmpty<K>, sourceMap: any): any;

Type parameters

NameConstraintsDescription
KUK
V

Parameters

NameTypeDescription
orderList.NonEmpty<K>
sourceMapany

empty

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

Definition

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

Type parameters

NameConstraintsDescription
KUK
V
example
HashMap.empty<number, string>()    // => HashMap<number, string>
HashMap.empty<string, boolean>() // => HashMap<string, boolean>

Overrides

Factory.empty

from

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

Definitions

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

from<K, V>(...sources: ArrayNonEmpty<StreamSource<readonly [K, V]>>): WithKeyValue<Tp, K, V>['normal'];

Type parameters

NameConstraintsDescription
KUK
V

Parameters

NameTypeDescription
sourcesArrayNonEmpty<StreamSource.NonEmpty<readonly [K, V]>>an array of StreamSource instances containing key-value entries
example
HashMap.from([[1, 'a'], [2, 'b']])    // => HashMap.NonEmpty<number, string>

Overrides

Factory.from

isNonEmptyInstance

undocumented

Definition

isNonEmptyInstance(source: any): source is any;

Parameters

NameTypeDescription
sourceany

Overrides

ContextBase.isNonEmptyInstance

isValidKey

undocumented

Definition

isValidKey(key: any): key is UK;

Parameters

NameTypeDescription
keyany

Overrides

ContextBase.isValidKey, Context.isValidKey

merge

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.

Definitions

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'];

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'];

Type parameters

NameConstraintsDescription
KUKthe common key type
Ireadonly [unknown, unknown, ...unknown[]]the array of input source value types

Parameters

NameTypeDescription
sources{
      [KT in keyof I]: StreamSource.NonEmpty<readonly [K, I[KT]]>;
    } & unknown[]
a non-empty set of StreamSouces containing tuples of keys and values
example
const m = HashMap.of([1, 'a'], [2, 'b'])
const m2 = HashMap.merge(m, [[2, true]], HashMap.of([2, 15]))
// type of m2: HashMap<number, [string, boolean, number]>
console.log(m2.toArray())
// => [[2, ['b', true, 15]]]

Overrides

Factory.merge

mergeAll

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.

Definitions

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'];

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'];

Type parameters

NameConstraintsDescription
Othe type of the fill value
Ireadonly [unknown, unknown, ...unknown[]]the array of input source value types
KUKthe common key type

Parameters

NameTypeDescription
fillValueOthe value to use for the result tuple if a source does not have a certain key
sources{
      [KT in keyof I]: StreamSource.NonEmpty<readonly [K, I[KT]]>;
    } & unknown[]
a non-empty set of StreamSouces containing tuples of keys and values
example
const m = HashMap.of([1, 'a'], [2, 'b'])
const m2 = HashMap.mergeAll('none', m, [[2, true]], HashMap.of([3, 15]))
// type of m2: HashMap<number, [string, boolean | string, number | string]>
console.log(m2.toArray())
// => [[1, ['a', 'none', 'none']], [2, ['b', true, 'none']], [3, ['none', 'none', 15]]]

Overrides

Factory.mergeAll

mergeAllWith

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.

Definitions

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'];

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'];

Type parameters

NameConstraintsDescription
Ireadonly [unknown, unknown, ...unknown[]]the array of input source value types
KUKthe common key type

Parameters

NameTypeDescription
sources{
      [KT in keyof I]: StreamSource.NonEmpty<readonly [K, I[KT]]>;
    } & unknown[]
a non-empty set of StreamSouces containing tuples of keys and values
example
const m = HashMap.of([1, 'a'], [2, 'b'])
const m2 = HashMap.mergeAllWith(
m
[[2, 'c']],
HashMap.of([3, 'd'])
)(
'q',
(key, v1, v2, v3) => `${key}${v1}${v2}${v3}`
)
// type of m2: HashMap<number, string>
console.log(m2.toArray())
// => [[1, '1aqq'], [2, '2bcq'], [3, '3qqd']]

Overrides

Factory.mergeAllWith

mergeWith

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.

Definitions

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'];

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'];

Type parameters

NameConstraintsDescription
Ireadonly [unknown, unknown, ...unknown[]]the array of input source value types
KUKthe common key type

Parameters

NameTypeDescription
sources{
      [KT in keyof I]: StreamSource.NonEmpty<readonly [K, I[KT]]>;
    } & unknown[]
a non-empty set of StreamSouces containing tuples of keys and values
example
const m = HashMap.of([1, 'a'], [2, 'b'])
const m2 = HashMap.mergeWith(
m,
[[2, true]],
HashMap.of([2, 15])
)(
(key, v1, v2) => `${key}${v1}${v2}`,
)
// type of m2: HashMap<number, string>
console.log(m2.toArray())
// => [[2, '2true15']]

Overrides

Factory.mergeWith

of

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

Definition

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

Type parameters

NameConstraintsDescription
KUK
V

Parameters

NameTypeDescription
entriesArrayNonEmpty<readonly [K, V]>a non-empty array of key-value entries
example
HashMap.of([1, 'a'], [2, 'b'])    // => HashMap.NonEmpty<number, string>

Overrides

Factory.of

reducer

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.

Definition

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

Type parameters

NameConstraintsDescription
KUK
V

Parameters

NameTypeDescription
sourceStreamSource<readonly [K, V]>(optional) an initial source of tuples to add to
example
const someSource = HashMap.of([1, 'a'], [2, 'b']);
const result = Stream.of([1, 'c'], [3, 'a']).reduce(HashMap.reducer(someSource))
result.toArray() // => [[1, 'c'], [2, 'b'], [3, 'a']]
note

uses a builder under the hood. If the given source is an RMap in the same context, it will directly call .toBuilder().

Overrides

Factory.reducer