class ListContext
undocumented
Implements: List.Context
Properties
_types
undocumented
_types
builder
undocumented
builder
Definition
readonly builder: <T>() =>
GenBuilder
<T>;
from
undocumented
from
Definition
readonly from: <T>(sources_0:
StreamSource
<T>, ...sources_1:
StreamSource
<T>[]) => any;
fromString
undocumented
fromString
Definition
readonly fromString: (sources_0: string, ...sources_1: string[]) => any;
of
undocumented
of
Definition
readonly of: <T>(values_0: T, ...values_1: T[]) =>
List.NonEmpty
<T>;
reducer
undocumented
reducer
Definition
readonly reducer: <T>(source?:
StreamSource
<T>) => Reducer<T,
List
<T>>;
typeTag
undocumented
typeTag
Methods
builder
Returns an empty List Builder based on this context.
builder
Definition
builder<T>():
List.Builder
<T>;
Type parameters
Name | Description |
---|---|
T | the List element type |
List.builder<number>() // => List.Builder<number>
Overrides
createBuilder
undocumented
createBuilder
empty
Returns the (singleton) empty List for this context with given value type.
empty
flatten
Returns, if T is a valid StreamSource
, the result of concatenating all streamable elements of the given sources.
flatten
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
Name | Constraints | Description |
---|---|---|
T | StreamSource.NonEmpty <unknown> | the element type |
Parameters
Name | Type | Description |
---|---|---|
source | StreamSource.NonEmpty <T> | a StreamSource containing StreamSource instances of values to concatenate |
const m = List.of([1, 2], [3, 4, 5])
List.flatten(m).toArray() // => [1, 2, 3, 4, 5]
Overrides
from
Returns an immutable set of this collection type and context, containing the given values in source
.
from
source
.Definitions
from<T>(...sources:
ArrayNonEmpty
<
StreamSource.NonEmpty
<T>>):
List.NonEmpty
<T>;
from<T>(...sources:
ArrayNonEmpty
<
StreamSource
<T>>):
List
<T>;
Type parameters
Name | Description |
---|---|
T | the element type |
Parameters
Name | Type | Description |
---|---|---|
sources | ArrayNonEmpty < StreamSource.NonEmpty <T>> | a non-empty array of StreamSource instances containing values |
List.from([1, 2, 3], [4, 5]).toArray()
// => [1, 2, 3, 4, 5]
Overrides
fromString
Returns a List of characters from the given strings in sources
.
fromString
sources
.Definitions
fromString<S extends string>(...sources:
ArrayNonEmpty
<
StringNonEmpty
<S>>):
List.NonEmpty
<string>;
fromString(...sources:
ArrayNonEmpty
<string>):
List
<string>;
Type parameters
Name | Constraints | Description |
---|---|---|
S | string | the source string type |
Parameters
Name | Type | Description |
---|---|---|
sources | ArrayNonEmpty < StringNonEmpty <S>> | a non-empty array containing strings |
List.fromString('abc').toArray() // => ['a', 'b', 'c']
Overrides
isLeafBlock
undocumented
isLeafBlock
isLeafBlockBuilder
undocumented
isLeafBlockBuilder
Definition
isLeafBlockBuilder<T>(obj:
LeafBuilder
<T>): obj is
LeafBlockBuilder
<T>;
Type parameters
Name | Description |
---|---|
T |
Parameters
Name | Type | Description |
---|---|---|
obj | LeafBuilder <T> |
isLeafTree
undocumented
isLeafTree
isLeafTreeBuilder
undocumented
isLeafTreeBuilder
Definition
isLeafTreeBuilder<T>(obj:
LeafBuilder
<T>): obj is
LeafTreeBuilder
<T>;
Type parameters
Name | Description |
---|---|
T |
Parameters
Name | Type | Description |
---|---|---|
obj | LeafBuilder <T> |
isNonLeafBlock
undocumented
isNonLeafBlock
isNonLeafBlockBuilder
undocumented
isNonLeafBlockBuilder
Definition
isNonLeafBlockBuilder<T>(obj:
NonLeafBuilder
<T, any>): obj is
NonLeafBlockBuilder
<T, any>;
Type parameters
Name | Description |
---|---|
T |
Parameters
Name | Type | Description |
---|---|---|
obj | NonLeafBuilder <T, any> |
isNonLeafTree
undocumented
isNonLeafTree
isReversedLeafBlock
undocumented
isReversedLeafBlock
leafBlock
undocumented
leafBlock
leafBlockBuilder
undocumented
leafBlockBuilder
Definition
leafBlockBuilder<T>(children: T[]):
LeafBlockBuilder
<T>;
Type parameters
Name | Description |
---|---|
T |
Parameters
Name | Type | Description |
---|---|---|
children | T[] |
leafBlockBuilderSource
undocumented
leafBlockBuilderSource
leafTree
undocumented
leafTree
leafTreeBuilder
undocumented
leafTreeBuilder
Definition
leafTreeBuilder<T>(left:
LeafBlockBuilder
<T>, right:
LeafBlockBuilder
<T>, middle?:
NonLeafBuilder
<T,
LeafBlockBuilder
<T>>, length?: number):
LeafTreeBuilder
<T>;
Type parameters
Name | Description |
---|---|
T |
Parameters
Name | Type | Description |
---|---|---|
left | LeafBlockBuilder <T> | |
right | LeafBlockBuilder <T> | |
middle | NonLeafBuilder <T, LeafBlockBuilder <T>> | |
length | number |
leafTreeBuilderSource
undocumented
leafTreeBuilderSource
nonLeafBlock
undocumented
nonLeafBlock
nonLeafBlockBuilder
undocumented
nonLeafBlockBuilder
Definition
nonLeafBlockBuilder<T, C extends
BlockBuilder
<T>>(level: number, children: C[], length: number):
NonLeafBlockBuilder
<T, C>;
Type parameters
Name | Constraints | Description |
---|---|---|
T | ||
C | BlockBuilder <T> |
Parameters
Name | Type | Description |
---|---|---|
level | number | |
children | C[] | |
length | number |
nonLeafBlockBuilderSource
undocumented
nonLeafBlockBuilderSource
Definition
nonLeafBlockBuilderSource<T, C extends
BlockBuilder
<T>>(source:
NonLeafBlock
<T, any>):
NonLeafBlockBuilder
<T, C>;
Type parameters
Name | Constraints | Description |
---|---|---|
T | ||
C | BlockBuilder <T> |
Parameters
Name | Type | Description |
---|---|---|
source | NonLeafBlock <T, any> |
nonLeafTree
undocumented
nonLeafTree
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
Name | Constraints | Description |
---|---|---|
T | ||
C | Block <T, C> |
Parameters
Name | Type | Description |
---|---|---|
left | NonLeafBlock <T, C> | |
right | NonLeafBlock <T, C> | |
middle | NonLeaf <T, NonLeafBlock <T, C>> | null | |
level | number |
nonLeafTreeBuilder
undocumented
nonLeafTreeBuilder
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
Name | Constraints | Description |
---|---|---|
T | ||
C | BlockBuilder <T> |
Parameters
Name | Type | Description |
---|---|---|
level | number | |
left | NonLeafBlockBuilder <T, C> | |
right | NonLeafBlockBuilder <T, C> | |
middle | NonLeafBuilder <T, NonLeafBlockBuilder <T, C>> | |
length | number |
nonLeafTreeBuilderSource
undocumented
nonLeafTreeBuilderSource
Definition
nonLeafTreeBuilderSource<T, C extends
BlockBuilder
<T>>(source:
NonLeafTree
<T, any>):
NonLeafTreeBuilder
<T, C>;
Type parameters
Name | Constraints | Description |
---|---|---|
T | ||
C | BlockBuilder <T> |
Parameters
Name | Type | Description |
---|---|---|
source | NonLeafTree <T, any> |
of
Returns an immutable set of this type and context, containing the given values
.
of
values
.Definition
of<T>(...values:
ArrayNonEmpty
<T>):
List.NonEmpty
<T>;
Type parameters
Name | Description |
---|---|
T | the element type |
Parameters
Name | Type | Description |
---|---|---|
values | ArrayNonEmpty <T> | a non-empty array of values |
List.of(1, 2, 3).toArray() // => [1, 2, 3]
Overrides
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.
reducer
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
Name | Description |
---|---|
T | the element type |
Parameters
Name | Type | Description |
---|---|---|
source | StreamSource <T> | (optional) an initial source of elements to append to |
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]
uses a List builder under the hood. If the given source
is a List in the same context, it will directly call .toBuilder()
.
Overrides
reversedLeaf
undocumented
reversedLeaf
Definition
reversedLeaf<T>(children: readonly T[]):
ReversedLeafBlock
<T>;
Type parameters
Name | Description |
---|---|
T |
Parameters
Name | Type | Description |
---|---|---|
children | readonly T[] |
unzip
Returns an array of Lists, where each list contains the values of the corresponding index of tuple T.
unzip
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
Name | Constraints | Description |
---|---|---|
T | readonly unknown[] & { length: L; } | the StreamSource tuple element type |
L | number | the tuple element length |
Parameters
Name | Type | Description |
---|---|---|
source | StreamSource.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 |
const m = List.of([1, 'a'], [2, 'b'])
List.unzip(m) // => [List.NonEmpty<number>, List.NonEmpty<string>]