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

x/rimbu/table/custom/interface/base.ts>VariantTableBase

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
namespace VariantTableBase
import { VariantTableBase } from "https://deno.land/x/rimbu@0.13.1/table/custom/interface/base.ts";

Interfaces

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

interface VariantTableBase
implements FastIterable<[R, C, V]>
import { type VariantTableBase } from "https://deno.land/x/rimbu@0.13.1/table/custom/interface/base.ts";

Properties

readonly
rowMap: WithRow<Tp, R, C, V>["rowMap"]

Returns the Map representation of this collection.

readonly
isEmpty: boolean

Returns true if the collection is empty.

readonly
size: number

Returns the amount of entries in the collection.

readonly
amountRows: number

Returns the amount of rows in the collection.

Methods

nonEmpty(): this is WithRow<Tp, R, C, V>["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(): WithRow<Tp, R, C, V>["nonEmpty"]

Returns the collection as a .NonEmpty type

stream(): Stream<[R, C, V]>

Returns a Stream containing all entries of this collection as tuples of row key, column key, and value.

streamRows(): Stream<R>

Returns a Stream containing all row keys of this collection.

streamValues(): Stream<V>

Returns a Stream containing all values of this collection.

hasRowKey<UR = R>(row: RelatedTo<R, UR>): boolean

Returns true if given row key is in the collection.

hasValueAt<UR = R, UC = C>(row: RelatedTo<R, UR>, column: RelatedTo<C, UC>): boolean

Returns true if the collection has a value for given row and column keys.

get<UR = R, UC = C>(row: RelatedTo<R, UR>, column: RelatedTo<C, UC>): V | undefined

Returns the value at given row and column keys, or the otherwise value if no value is present.

get<UR, UC, O>(
row: RelatedTo<R, UR>,
column: RelatedTo<C, UC>,
otherwise: OptLazy<O>,
): V | O
getRow<UR = R>(row: RelatedTo<R, UR>): WithRow<Tp, R, C, V>["row"]

Returns a map containing the column keys and values in the given row.

remove<UR = R, UC = C>(row: RelatedTo<R, UR>, column: RelatedTo<C, UC>): WithRow<Tp, R, C, V>["normal"]

Returns the collection where the value at given row and column keys is removed.

removeRow<UR = R>(row: RelatedTo<R, UR>): WithRow<Tp, R, C, V>["normal"]

Returns the collection where all values in given row are removed.

removeAndGet<UR = R, UC = C>(row: RelatedTo<R, UR>, column: RelatedTo<C, UC>): [WithRow<Tp, R, C, V>["normal"], V] | undefined

Returns a tuple containing the collection with the value at given row and column removed, and the removed value. If no such value is found, it returns undefined.

removeRowAndGet<UR = R>(row: RelatedTo<R, UR>): [WithRow<Tp, R, C, V>["normal"], WithRow<Tp, R, C, V>["rowNonEmpty"]] | undefined

Returns a tuple containing the collection with the values at given row removed, and a map containing the removed columns and values. If no such row is found, it returns undefined.

removeRows<UR = R>(rows: StreamSource<RelatedTo<R, UR>>): WithRow<Tp, R, C, V>["normal"]

Returns the collection where the values for each row key in given rows are removed.

removeEntries<UR = R, UC = C>(entries: StreamSource<[RelatedTo<R, UR>, RelatedTo<C, UC>]>): WithRow<Tp, R, C, V>["normal"]

Returns the collection where the given entries are removed.

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

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

filter(pred: (
entry: [R, C, V],
index: number,
halt: () => void,
) => boolean
): WithRow<Tp, R, C, V>["normal"]

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

filterRows(pred: (
entry: readonly [R, WithRow<Tp, R, C, V>["rowNonEmpty"]],
index: number,
halt: () => void,
) => boolean
): WithRow<Tp, R, C, V>["normal"]

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

mapValues<V2>(mapFun: (
value: V,
row: R,
column: C,
) => V2
): (Tp & Row<R, C, V2>)["normal"]

Returns a collection with the same row and column keys, but where the given mapFun function is applied to each entry value.

toArray(): [R, C, V][]

Returns an array containing all entries in this collection.

toString(): string

Returns a string representation of this collection.

toJSON(): ToJSON<[R, [C, V][]][]>

Returns a JSON representation of this collection.