Skip to main content

class ListContext

undocumented

Implements: List.Context

Properties

_empty

undocumented

Definition

readonly _empty: List<any>;

_types

undocumented

Definition

get _types(): List.Types;

Overrides

Context._types

blockSizeBits

undocumented

Definition

readonly blockSizeBits: number;

builder

undocumented

Definition

readonly builder: <T>() => GenBuilder<T>;

empty

undocumented

Definition

readonly empty: <T>() => List<T>;

flatten

undocumented

Definition

readonly flatten: (source: any) => any;

from

undocumented

Definition

readonly from: <T>(sources_0: StreamSource<T>, ...sources_1: StreamSource<T>[]) => any;

fromString

undocumented

Definition

readonly fromString: (sources_0: string, ...sources_1: string[]) => any;

maxBlockSize

undocumented

Definition

readonly maxBlockSize: number;

minBlockSize

undocumented

Definition

readonly minBlockSize: number;

of

undocumented

Definition

readonly of: <T>(values_0: T, ...values_1: T[]) => List.NonEmpty<T>;

reducer

undocumented

Definition

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

typeTag

undocumented

Definition

get typeTag(): 'List';

Overrides

Context.typeTag

unzip

undocumented

Definition

readonly unzip: (source: any, options: {
    length: number;
  }) => any;

Methods

builder

Returns an empty List Builder based on this context.

Definition

builder<T>(): List.Builder<T>;

Type parameters

NameDescription
Tthe List element type
example
List.builder<number>()   // => List.Builder<number>

Overrides

ListFactory.builder

createBuilder

undocumented

Definition

createBuilder<T>(source?: List<T>): GenBuilder<T>;

Type parameters

NameDescription
T

Parameters

NameTypeDescription
sourceList<T>

createCacheMap

undocumented

Definition

createCacheMap(): CacheMap;

empty

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

Definition

empty<T>(): List<T>;

Type parameters

NameDescription
Tthe element type
example
List.empty<number>()    // => List<number>
List.empty<string>() // => List<string>

Overrides

ListFactory.empty

flatten

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

Definitions

flatten<T extends StreamSource.NonEmpty<unknown>>(source: StreamSource.NonEmpty<T>): T extends StreamSource.NonEmpty<infer S> ? List.NonEmpty<S> : never;

flatten<T extends StreamSource<unknown>>(source: StreamSource<T>): T extends StreamSource<infer S> ? List<S> : never;

Type parameters

NameConstraintsDescription
TStreamSource.NonEmpty<unknown>the element type

Parameters

NameTypeDescription
sourceStreamSource.NonEmpty<T>a StreamSource containing StreamSource instances of values to concatenate
example
const m = List.of([1, 2], [3, 4, 5])
List.flatten(m).toArray() // => [1, 2, 3, 4, 5]

Overrides

ListFactory.flatten

from

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

Definitions

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

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

Type parameters

NameDescription
Tthe element type

Parameters

NameTypeDescription
sourcesArrayNonEmpty<StreamSource.NonEmpty<T>>a non-empty array of StreamSource instances containing values
example
List.from([1, 2, 3], [4, 5]).toArray()
// => [1, 2, 3, 4, 5]

Overrides

ListFactory.from

fromString

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

Definitions

fromString<S extends string>(...sources: ArrayNonEmpty<StringNonEmpty<S>>): List.NonEmpty<string>;

fromString(...sources: ArrayNonEmpty<string>): List<string>;

Type parameters

NameConstraintsDescription
Sstringthe source string type

Parameters

NameTypeDescription
sourcesArrayNonEmpty<StringNonEmpty<S>>a non-empty array containing strings
example
List.fromString('abc').toArray()   // => ['a', 'b', 'c']

Overrides

ListFactory.fromString

isLeafBlock

undocumented

Definition

isLeafBlock<T>(obj: List<T> | Block<T>): obj is LeafBlock<T>;

Type parameters

NameDescription
T

Parameters

NameTypeDescription
objList<T> | Block<T>

isLeafBlockBuilder

undocumented

Definition

isLeafBlockBuilder<T>(obj: LeafBuilder<T>): obj is LeafBlockBuilder<T>;

Type parameters

NameDescription
T

Parameters

NameTypeDescription
objLeafBuilder<T>

isLeafTree

undocumented

Definition

isLeafTree<T>(obj: List<T>): obj is LeafTree<T>;

Type parameters

NameDescription
T

Parameters

NameTypeDescription
objList<T>

isLeafTreeBuilder

undocumented

Definition

isLeafTreeBuilder<T>(obj: LeafBuilder<T>): obj is LeafTreeBuilder<T>;

Type parameters

NameDescription
T

Parameters

NameTypeDescription
objLeafBuilder<T>

isNonLeafBlock

undocumented

Definition

isNonLeafBlock<T>(obj: List<T> | Block<T> | NonLeaf<T>): obj is NonLeafBlock<T, any>;

Type parameters

NameDescription
T

Parameters

NameTypeDescription
objList<T> | Block<T> | NonLeaf<T>

isNonLeafBlockBuilder

undocumented

Definition

isNonLeafBlockBuilder<T>(obj: NonLeafBuilder<T, any>): obj is NonLeafBlockBuilder<T, any>;

Type parameters

NameDescription
T

Parameters

NameTypeDescription
objNonLeafBuilder<T, any>

isNonLeafTree

undocumented

Definition

isNonLeafTree<T>(obj: NonLeaf<T>): obj is NonLeafTree<T, any>;

Type parameters

NameDescription
T

Parameters

NameTypeDescription
objNonLeaf<T>

isReversedLeafBlock

undocumented

Definition

isReversedLeafBlock<T>(obj: List<T> | Block<T>): obj is ReversedLeafBlock<T>;

Type parameters

NameDescription
T

Parameters

NameTypeDescription
objList<T> | Block<T>

leafBlock

undocumented

Definition

leafBlock<T>(children: readonly T[]): LeafBlock<T>;

Type parameters

NameDescription
T

Parameters

NameTypeDescription
childrenreadonly T[]

leafBlockBuilder

undocumented

Definition

leafBlockBuilder<T>(children: T[]): LeafBlockBuilder<T>;

Type parameters

NameDescription
T

Parameters

NameTypeDescription
childrenT[]

leafBlockBuilderSource

undocumented

Definition

leafBlockBuilderSource<T>(source: LeafBlock<T>): LeafBlockBuilder<T>;

Type parameters

NameDescription
T

Parameters

NameTypeDescription
sourceLeafBlock<T>

leafTree

undocumented

Definition

leafTree<T>(left: LeafBlock<T>, right: LeafBlock<T>, middle: NonLeaf<T, LeafBlock<T>> |null):LeafTree<T>;

Type parameters

NameDescription
T

Parameters

NameTypeDescription
leftLeafBlock<T>
rightLeafBlock<T>
middleNonLeaf<T, LeafBlock<T>> | null

leafTreeBuilder

undocumented

Definition

leafTreeBuilder<T>(left: LeafBlockBuilder<T>, right: LeafBlockBuilder<T>, middle?: NonLeafBuilder<T, LeafBlockBuilder<T>>, length?: number): LeafTreeBuilder<T>;

Type parameters

NameDescription
T

Parameters

NameTypeDescription
leftLeafBlockBuilder<T>
rightLeafBlockBuilder<T>
middleNonLeafBuilder<T, LeafBlockBuilder<T>>
lengthnumber

leafTreeBuilderSource

undocumented

Definition

leafTreeBuilderSource<T>(source: LeafTree<T>): LeafTreeBuilder<T>;

Type parameters

NameDescription
T

Parameters

NameTypeDescription
sourceLeafTree<T>

nonLeafBlock

undocumented

Definition

nonLeafBlock<T, C extends Block<T, C>>(length: number, children: readonly C[], level: number): NonLeafBlock<T, C>;

Type parameters

NameConstraintsDescription
T
CBlock<T, C>

Parameters

NameTypeDescription
lengthnumber
childrenreadonly C[]
levelnumber

nonLeafBlockBuilder

undocumented

Definition

nonLeafBlockBuilder<T, C extends BlockBuilder<T>>(level: number, children: C[], length: number): NonLeafBlockBuilder<T, C>;

Type parameters

NameConstraintsDescription
T
CBlockBuilder<T>

Parameters

NameTypeDescription
levelnumber
childrenC[]
lengthnumber

nonLeafBlockBuilderSource

undocumented

Definition

nonLeafBlockBuilderSource<T, C extends BlockBuilder<T>>(source: NonLeafBlock<T, any>): NonLeafBlockBuilder<T, C>;

Type parameters

NameConstraintsDescription
T
CBlockBuilder<T>

Parameters

NameTypeDescription
sourceNonLeafBlock<T, any>

nonLeafTree

undocumented

Definition

nonLeafTree<T, C extends Block<T, C>>(left: NonLeafBlock<T, C>, right: NonLeafBlock<T, C>, middle: NonLeaf<T, NonLeafBlock<T, C>> |null, level: number):NonLeafTree<T, C>;

Type parameters

NameConstraintsDescription
T
CBlock<T, C>

Parameters

NameTypeDescription
leftNonLeafBlock<T, C>
rightNonLeafBlock<T, C>
middleNonLeaf<T, NonLeafBlock<T, C>> | null
levelnumber

nonLeafTreeBuilder

undocumented

Definition

nonLeafTreeBuilder<T, C extends BlockBuilder<T>>(level: number, left: NonLeafBlockBuilder<T, C>, right: NonLeafBlockBuilder<T, C>, middle?: NonLeafBuilder<T, NonLeafBlockBuilder<T, C>>, length?: number): NonLeafTreeBuilder<T, C>;

Type parameters

NameConstraintsDescription
T
CBlockBuilder<T>

Parameters

NameTypeDescription
levelnumber
leftNonLeafBlockBuilder<T, C>
rightNonLeafBlockBuilder<T, C>
middleNonLeafBuilder<T, NonLeafBlockBuilder<T, C>>
lengthnumber

nonLeafTreeBuilderSource

undocumented

Definition

nonLeafTreeBuilderSource<T, C extends BlockBuilder<T>>(source: NonLeafTree<T, any>): NonLeafTreeBuilder<T, C>;

Type parameters

NameConstraintsDescription
T
CBlockBuilder<T>

Parameters

NameTypeDescription
sourceNonLeafTree<T, any>

of

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

Definition

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

Type parameters

NameDescription
Tthe element type

Parameters

NameTypeDescription
valuesArrayNonEmpty<T>a non-empty array of values
example
List.of(1, 2, 3).toArray()   // => [1, 2, 3]

Overrides

ListFactory.of

reducer

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.

Definition

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

Type parameters

NameDescription
Tthe element type

Parameters

NameTypeDescription
sourceStreamSource<T>(optional) an initial source of elements to append to
example
const someList = List.of(1, 2, 3);
const result = Stream.range({ start: 20, amount: 5 }).reduce(List.reducer(someList))
result.toArray() // => [1, 2, 3, 20, 21, 22, 23, 24]
note

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

Overrides

ListFactory.reducer

reversedLeaf

undocumented

Definition

reversedLeaf<T>(children: readonly T[]): ReversedLeafBlock<T>;

Type parameters

NameDescription
T

Parameters

NameTypeDescription
childrenreadonly T[]

unzip

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

Definitions

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

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

Type parameters

NameConstraintsDescription
Treadonly unknown[] & {
    length: L;
  }
the StreamSource tuple element type
Lnumberthe tuple element length

Parameters

NameTypeDescription
sourceStreamSource.NonEmpty<T>a StreamSource containing tuples of type T to unzip
options{
    length: L;
  }
an object containing the following properties:
- length: the length of the tuples in type T
example
const m = List.of([1, 'a'], [2, 'b'])
List.unzip(m) // => [List.NonEmpty<number>, List.NonEmpty<string>]

Overrides

ListFactory.unzip