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

x/rimbu/graph/custom/index.ts>GraphBase.Factory

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

Type Parameters

Tp extends GraphBase.Types
optional
UN = unknown

Methods

empty<N extends UN>(): WithGraphValues<Tp, N, unknown>["normal"]

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

of<N extends UN>(...graphElements: ArrayNonEmpty<GraphElement<N>>): WithGraphValues<Tp, N, unknown>["nonEmpty"]

Returns an immutable valued Graph instance containing the graph elements from the given graphElements.

from<N extends UN>(...sources: ArrayNonEmpty<StreamSource.NonEmpty<GraphElement<N>>>): WithGraphValues<Tp, N, unknown>["nonEmpty"]

Returns an immutable valued Graph, containing the graph elements from each of the given sources.

from<N extends UN>(...sources: ArrayNonEmpty<StreamSource<GraphElement<N>>>): WithGraphValues<Tp, N, unknown>["normal"]
builder<N extends UN>(): WithGraphValues<Tp, N, unknown>["builder"]

Returns an empty builder instance.

reducer<N extends UN>(source?: StreamSource.NonEmpty<GraphElement<N>>): Reducer<GraphElement<N>, WithGraphValues<Tp, N, unknown>["normal"]>

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