Skip to main content
Module

x/rimbu/list/custom/index.ts>ListFactory

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

Methods

empty<T>(): List<T>

Returns the (singleton) empty List for this context with given value type.

of<T>(...values: ArrayNonEmpty<T>): List.NonEmpty<T>

Returns an immutable set of this type and context, containing the given values.

from<T>(...sources: ArrayNonEmpty<StreamSource.NonEmpty<T>>): List.NonEmpty<T>

Returns an immutable set of this collection type and context, containing the given values in source.

from<T>(...sources: ArrayNonEmpty<StreamSource<T>>): List<T>
fromString<S extends string>(...sources: ArrayNonEmpty<StringNonEmpty<S>>): List.NonEmpty<string>

Returns a List of characters from the given strings in sources.

fromString(...sources: ArrayNonEmpty<string>): List<string>
flatten<T extends StreamSource.NonEmpty<unknown>>(source: StreamSource.NonEmpty<T>): T extends StreamSource.NonEmpty<infer S> ? List.NonEmpty<S> : never

Returns, if T is a valid StreamSource, the result of concatenating all streamable elements of the given sources.

flatten<T extends StreamSource<unknown>>(source: StreamSource<T>): T extends StreamSource<infer S> ? List<S> : never
unzip<T extends readonly unknown[] & { length: L; }, L extends number>(source: StreamSource.NonEmpty<T>, length: L): [K in keyof T]: List.NonEmpty<T[K]>

Returns an array of Lists, where each list contains the values of the corresponding index of tuple T.

unzip<T extends readonly unknown[] & { length: L; }, L extends number>(source: StreamSource<T>, length: L): [K in keyof T]: List<T[K]>
builder<T>(): List.Builder<T>

Returns an empty List Builder based on this context.

reducer<T>(source?: StreamSource<T>): Reducer<T, List<T>>

Returns a Reducer that appends received items to a List and returns the List as a result. When a source is given, the reducer will first create a List from the source, and then append elements to it.