@esfx/iter-fn Package
An iteration and query API for ECMAScript iterables.
Installation
npm i @esfx/iter-fn
Usage
import { map } from "@esfx/iter-fn";
const x = map([1, 2, 3], x => x * 2);
x; // [2, 4, 6]
Interfaces
ConsumeOptions
Functions
ancestors(source, predicate)
Selects the ancestors of each node in the iterable. This is equivalent to the ancestor::*
selector in XPath.
Hierarchy
Declaration
export declare function ancestors<TNode, U extends TNode>(source: HierarchyIterable<TNode>, predicate: (element: TNode) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- U
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => element is U
Returns
ancestors(source, predicate)
Declaration
export declare function ancestors<TNode>(source: HierarchyIterable<TNode>, predicate?: (element: TNode) => boolean): HierarchyIterable<TNode>;
Type Parameters
- TNode
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => boolean
Returns
ancestorsAndSelf(source, predicate)
Selects the ancestors of each node in the iterable, along with the node itself. This is equivalent to the ancestor-or-self::*
selector in XPath.
Hierarchy
Declaration
export declare function ancestorsAndSelf<TNode, U extends TNode>(source: HierarchyIterable<TNode>, predicate: (element: TNode) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- U
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => element is U
Returns
ancestorsAndSelf(source, predicate)
Declaration
export declare function ancestorsAndSelf<TNode>(source: HierarchyIterable<TNode>, predicate?: (element: TNode) => boolean): HierarchyIterable<TNode>;
Type Parameters
- TNode
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => boolean
Returns
append(source, value)
Creates an Iterable
for the elements of source
with the provided value
appended to the
end.
Declaration
export declare function append<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, value: T): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- value
- T
The value to append. Subquery
Returns
append(source, value)
Creates an Iterable
for the elements of source
with the provided value
appended to the
end.
Declaration
export declare function append<T>(source: Iterable<T>, value: T): Iterable<T>;
Type Parameters
- T
Parameters
- value
- T
The value to append. Subquery
Returns
average(source)
Computes the average for a series of numbers.
Declaration
export declare function average(source: Iterable<number>): number;
Parameters
Returns
average(source, elementSelector)
Computes the average for a series of numbers.
Declaration
export declare function average<T>(source: Iterable<T>, elementSelector: (element: T) => number): number;
Type Parameters
- T
Parameters
- elementSelector
- (element: T) => number
A callback used to convert a value in source
to a number.
Scalar
Returns
bottomMost(source, predicate, equaler)
Creates a HierarchyIterable
for the bottom-most elements of a HierarchyIterable
.
Elements of source
that are an ancestor of any other element of source
are removed.
Declaration
export declare function bottomMost<TNode, T extends TNode, U extends T>(source: HierarchyIterable<TNode, T>, predicate: (value: T) => value is U, equaler?: Equaler<TNode>): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- T
- U
Parameters
- predicate
- (value: T) => value is U
An optional callback used to filter the results. Hierarchy
- equaler
- Equaler<TNode>
Returns
bottomMost(source, predicate, equaler)
Creates a HierarchyIterable
for the bottom-most elements of a HierarchyIterable
.
Elements of source
that are an ancestor of any other element of source
are removed.
Declaration
export declare function bottomMost<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, predicate?: (value: T) => boolean, equaler?: Equaler<TNode>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- predicate
- (value: T) => boolean
An optional callback used to filter the results.
Returns
children(source, predicate)
Selects the children of each node in the iterable. This is equivalent to the child::*
selector in XPath, or the >
combinator in CSS.
Hierarchy
Declaration
export declare function children<TNode, U extends TNode>(source: HierarchyIterable<TNode>, predicate: (element: TNode) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- U
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => element is U
Returns
children(source, predicate)
Declaration
export declare function children<TNode>(source: HierarchyIterable<TNode>, predicate?: (element: TNode) => boolean): HierarchyIterable<TNode>;
Type Parameters
- TNode
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => boolean
Returns
concat(left, right)
Creates an Iterable
that concatenates two Iterable
objects.
Declaration
export declare function concat<TNode, T extends TNode>(left: HierarchyIterable<TNode, T>, right: Iterable<T>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
Returns
concat(left, right)
Creates an Iterable
that concatenates two Iterable
objects.
Declaration
export declare function concat<TNode, T extends TNode>(left: Iterable<T>, right: HierarchyIterable<TNode, T>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
Returns
concat(left, right)
Creates an Iterable
that concatenates two Iterable
objects.
Declaration
export declare function concat<T>(left: Iterable<T>, right: Iterable<T>): Iterable<T>;
Type Parameters
- T
Parameters
Returns
consume(iterator, options)
Creates an Iterable
that, when iterated, consumes the provided Iterator
.
Declaration
export declare function consume<T>(iterator: Iterator<T>, options?: ConsumeOptions): Iterable<T>;
Type Parameters
- T
Parameters
- options
- ConsumeOptions
Returns
continuous(value)
Creates an Iterable
that repeats the provided value forever.
Declaration
export declare function continuous<T>(value: T): Iterable<T>;
Type Parameters
- T
Parameters
- value
- T
The value for each element of the Iterable
.
Query
Returns
copyTo(source, collection, start, count)
Writes each element of a source iterable to a destination. The destination must already have enough space to write the requested number of elements (i.e. arrays are *not* resized).
Declaration
export declare function copyTo<T, U extends IndexedCollection<T> | T[]>(source: Iterable<T>, collection: U, start?: number, count?: number): U;
Type Parameters
- T
- U
Parameters
- collection
- U
The destination array or IndexedCollection
.
Returns
corresponds(left, right, equaler)
Computes a scalar value indicating whether every element in left
corresponds to a matching element
in right
at the same position.
Declaration
export declare function corresponds<T>(left: Iterable<T>, right: Iterable<T>, equaler?: EqualityComparison<T> | Equaler<T>): boolean;
Type Parameters
- T
Parameters
- equaler
- EqualityComparison<T> | Equaler<T>
An optional callback used to compare the equality of two elements. Scalar
Returns
corresponds(left, right, equaler)
Computes a scalar value indicating whether every element in left
corresponds to a matching element
in right
at the same position.
Declaration
export declare function corresponds<T, U>(left: Iterable<T>, right: Iterable<U>, equaler: (left: T, right: U) => boolean): boolean;
Type Parameters
- T
- U
Parameters
- equaler
- (left: T, right: U) => boolean
An optional callback used to compare the equality of two elements. Scalar
Returns
correspondsBy(left, right, keySelector, keyEqualer)
Computes a scalar value indicating whether the key for every element in left
corresponds to a matching key
in right
at the same position.
Declaration
export declare function correspondsBy<T, K>(left: Iterable<T>, right: Iterable<T>, keySelector: (element: T) => K, keyEqualer?: Equaler<K>): boolean;
Type Parameters
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for each element. Scalar
- keyEqualer
- Equaler<K>
Returns
correspondsBy(left, right, leftKeySelector, rightKeySelector, keyEqualer)
Computes a scalar value indicating whether the key for every element in left
corresponds to a matching key
in right
at the same position.
Declaration
export declare function correspondsBy<T, U, K>(left: Iterable<T>, right: Iterable<U>, leftKeySelector: (element: T) => K, rightKeySelector: (element: U) => K, keyEqualer?: EqualityComparison<K> | Equaler<K>): boolean;
Type Parameters
- T
- U
- K
Parameters
- leftKeySelector
- (element: T) => K
A callback used to select the key for each element in left
.
- rightKeySelector
- (element: U) => K
A callback used to select the key for each element in right
.
- keyEqualer
- EqualityComparison<K> | Equaler<K>
An optional callback used to compare the equality of two keys. Scalar
Returns
count(source, predicate)
Counts the number of elements, optionally filtering elements using the supplied callback.
Declaration
export declare function count<T>(source: Iterable<T>, predicate?: (element: T) => boolean): number;
Type Parameters
- T
Parameters
- predicate
- (element: T) => boolean
An optional callback used to match each element. Scalar
Returns
defaultIfEmpty(source, defaultValue)
Creates an Iterable
that contains the provided default value if source
contains no elements.
Declaration
export declare function defaultIfEmpty<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, defaultValue: T): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- defaultValue
- T
The default value. Subquery
Returns
defaultIfEmpty(source, defaultValue)
Creates an Iterable
that contains the provided default value if source
contains no elements.
Declaration
export declare function defaultIfEmpty<T>(source: Iterable<T>, defaultValue: T): Iterable<T>;
Type Parameters
- T
Parameters
- defaultValue
- T
The default value. Subquery
Returns
descendants(source, predicate)
Selects the descendents of each node in the iterable. This is equivalent to the descendant::*
selector in XPath, or the
(space) combinator in CSS.
Hierarchy
Declaration
export declare function descendants<TNode, U extends TNode>(source: HierarchyIterable<TNode>, predicate: (element: TNode) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- U
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => element is U
Returns
descendants(source, predicate)
Declaration
export declare function descendants<TNode>(source: HierarchyIterable<TNode>, predicate?: (element: TNode) => boolean): HierarchyIterable<TNode>;
Type Parameters
- TNode
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => boolean
Returns
descendantsAndSelf(source, predicate)
Selects the descendents of each node in the iterable, along with the node itself. This is equivalent to the descendant-or-self::*
selector in XPath.
Hierarchy
Declaration
export declare function descendantsAndSelf<TNode, U extends TNode>(source: HierarchyIterable<TNode>, predicate: (element: TNode) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- U
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => element is U
Returns
descendantsAndSelf(source, predicate)
Declaration
export declare function descendantsAndSelf<TNode>(source: HierarchyIterable<TNode>, predicate?: (element: TNode) => boolean): HierarchyIterable<TNode>;
Type Parameters
- TNode
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => boolean
Returns
distinct(source, keyEqualer)
Creates an Iterable
for the distinct elements of source
.
Subquery
Declaration
export declare function distinct<TNode, T extends TNode, K>(source: HierarchyIterable<TNode, T>, keyEqualer?: Equaler<K>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
- K
Parameters
- keyEqualer
- Equaler<K>
Returns
distinct(source, equaler)
Creates an Iterable
for the distinct elements of source
.
Subquery
Declaration
export declare function distinct<T>(source: Iterable<T>, equaler?: Equaler<T>): Iterable<T>;
Type Parameters
- T
Parameters
Returns
distinctBy(source, keySelector, keyEqualer)
Creates an Iterable
for the distinct elements of source
.
Subquery
Declaration
export declare function distinctBy<TNode, T extends TNode, K>(source: HierarchyIterable<TNode, T>, keySelector: (value: T) => K, keyEqualer?: Equaler<K>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
- K
Parameters
- keySelector
- (value: T) => K
A callback used to select the key to determine uniqueness.
Returns
distinctBy(source, keySelector, keyEqualer)
Creates an Iterable
for the distinct elements of source
.
Subquery
Declaration
export declare function distinctBy<T, K>(source: Iterable<T>, keySelector: (value: T) => K, keyEqualer?: Equaler<K>): Iterable<T>;
Type Parameters
- T
- K
Parameters
- keySelector
- (value: T) => K
A callback used to select the key to determine uniqueness.
Returns
drop(source, count)
Creates a subquery containing all elements except the first elements up to the supplied count.
Declaration
export declare function drop<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, count: number): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
Returns
drop(source, count)
Creates a subquery containing all elements except the first elements up to the supplied count.
Declaration
export declare function drop<T>(source: Iterable<T>, count: number): Iterable<T>;
Type Parameters
- T
Parameters
Returns
dropRight(source, count)
Creates a subquery containing all elements except the last elements up to the supplied count.
Declaration
export declare function dropRight<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, count: number): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
Returns
dropRight(source, count)
Creates a subquery containing all elements except the last elements up to the supplied count.
Declaration
export declare function dropRight<T>(source: Iterable<T>, count: number): Iterable<T>;
Type Parameters
- T
Parameters
Returns
dropUntil(source, predicate)
Creates a subquery containing all elements except the first elements that do not match the supplied predicate.
Declaration
export declare function dropUntil<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, predicate: (element: T) => boolean): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- predicate
- (element: T) => boolean
A callback used to match each element. Subquery
Returns
dropUntil(source, predicate)
Creates a subquery containing all elements except the first elements that do not match the supplied predicate.
Declaration
export declare function dropUntil<T>(source: Iterable<T>, predicate: (element: T) => boolean): Iterable<T>;
Type Parameters
- T
Parameters
- predicate
- (element: T) => boolean
A callback used to match each element. Subquery
Returns
dropWhile(source, predicate)
Creates a subquery containing all elements except the first elements that match the supplied predicate.
Declaration
export declare function dropWhile<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, predicate: (element: T) => boolean): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- predicate
- (element: T) => boolean
A callback used to match each element. Subquery
Returns
dropWhile(source, predicate)
Creates a subquery containing all elements except the first elements that match the supplied predicate.
Declaration
export declare function dropWhile<T>(source: Iterable<T>, predicate: (element: T) => boolean): Iterable<T>;
Type Parameters
- T
Parameters
- predicate
- (element: T) => boolean
A callback used to match each element. Subquery
Returns
elementAt(source, offset)
Finds the value at the provided offset. A negative offset starts from the last element.
Declaration
export declare function elementAt<T>(source: Iterable<T>, offset: number | Index): T | undefined;
Type Parameters
- T
Parameters
Returns
empty()
Creates an Iterable
with no elements.
Query
Declaration
export declare function empty<T>(): Iterable<T>;
Type Parameters
- T
Returns
endsWith(left, right, equaler)
Computes a scalar value indicating whether the elements of left
end
with the same sequence of elements in right
.
Declaration
export declare function endsWith<T>(left: Iterable<T>, right: Iterable<T>, equaler?: EqualityComparison<T> | Equaler<T>): boolean;
Type Parameters
- T
Parameters
- equaler
- EqualityComparison<T> | Equaler<T>
An optional callback used to compare the equality of two elements. Scalar
Returns
endsWith(left, right, equaler)
Computes a scalar value indicating whether the elements of left
end
with the same sequence of elements in right
.
Declaration
export declare function endsWith<T, U>(left: Iterable<T>, right: Iterable<U>, equaler: (left: T, right: U) => boolean): boolean;
Type Parameters
- T
- U
Parameters
- equaler
- (left: T, right: U) => boolean
An optional callback used to compare the equality of two elements. Scalar
Returns
every(source, predicate)
Computes a scalar value indicating whether all elements match the supplied callback.
Declaration
export declare function every<T, U extends T>(source: Iterable<T>, predicate: (element: T) => element is U): source is Iterable<U>;
Type Parameters
- T
- U
Parameters
- predicate
- (element: T) => element is U
A callback used to match each element. Scalar
Returns
every(source, predicate)
Computes a scalar value indicating whether all elements match the supplied callback.
Declaration
export declare function every<T>(source: Iterable<T>, predicate: (element: T) => boolean): boolean;
Type Parameters
- T
Parameters
- predicate
- (element: T) => boolean
A callback used to match each element. Scalar
Returns
except(left, right, equaler)
Creates an Iterable
for the set difference between two Iterable
objects.
Declaration
export declare function except<TNode, T extends TNode>(left: HierarchyIterable<TNode, T>, right: Iterable<T>, equaler?: Equaler<T>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
Returns
except(left, right, equaler)
Creates an Iterable
for the set difference between two Iterable
objects.
Declaration
export declare function except<T>(left: Iterable<T>, right: Iterable<T>, equaler?: Equaler<T>): Iterable<T>;
Type Parameters
- T
Parameters
Returns
exceptBy(left, right, keySelector, keyEqualer)
Creates an Iterable
for the set difference between two Iterable
objects, where set identity is determined by the selected key.
Declaration
export declare function exceptBy<TNode, T extends TNode, K>(left: HierarchyIterable<TNode, T>, right: Iterable<T>, keySelector: (element: T) => K, keyEqualer?: Equaler<K>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for each element.
Returns
exceptBy(left, right, keySelector, keyEqualer)
Creates an Iterable
for the set difference between two Iterable
objects, where set identity is determined by the selected key.
Declaration
export declare function exceptBy<T, K>(left: Iterable<T>, right: Iterable<T>, keySelector: (element: T) => K, keyEqualer?: Equaler<K>): Iterable<T>;
Type Parameters
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for each element.
Returns
exclude(source, values)
Creates an Iterable
with every instance of the specified value removed.
Declaration
export declare function exclude<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, ...values: T[]): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- values
- T[]
The values to exclude. Subquery
Returns
exclude(source, values)
Creates an Iterable
with every instance of the specified value removed.
Declaration
export declare function exclude<T>(source: Iterable<T>, ...values: T[]): Iterable<T>;
Type Parameters
- T
Parameters
- values
- T[]
The values to exclude. Subquery
Returns
filter(source, predicate)
Creates an Iterable
whose elements match the supplied predicate.
Declaration
export declare function filter<TNode, T extends TNode, U extends T>(source: HierarchyIterable<TNode, T>, predicate: (element: T, offset: number) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- T
- U
Parameters
- predicate
- (element: T, offset: number) => element is U
A callback used to match each element. Subquery
Returns
filter(source, predicate)
Creates an Iterable
whose elements match the supplied predicate.
Declaration
export declare function filter<T, U extends T>(source: Iterable<T>, predicate: (element: T, offset: number) => element is U): Iterable<U>;
Type Parameters
- T
- U
Parameters
- predicate
- (element: T, offset: number) => element is U
A callback used to match each element. Subquery
Returns
filter(source, predicate)
Creates an Iterable
whose elements match the supplied predicate.
Declaration
export declare function filter<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, predicate: (element: T, offset: number) => boolean): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- predicate
- (element: T, offset: number) => boolean
A callback used to match each element. Subquery
Returns
filter(source, predicate)
Creates an Iterable
whose elements match the supplied predicate.
Declaration
export declare function filter<T>(source: Iterable<T>, predicate: (element: T, offset: number) => boolean): Iterable<T>;
Type Parameters
- T
Parameters
- predicate
- (element: T, offset: number) => boolean
A callback used to match each element. Subquery
Returns
filterBy(source, keySelector, predicate)
Creates an Iterable
where the selected key for each element matches the supplied predicate.
Declaration
export declare function filterBy<TNode, T extends TNode, K>(source: HierarchyIterable<TNode, T>, keySelector: (element: T) => K, predicate: (key: K, offset: number) => boolean): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for each element.
- predicate
- (key: K, offset: number) => boolean
A callback used to match each key. Subquery
Returns
filterBy(source, keySelector, predicate)
Creates an Iterable
where the selected key for each element matches the supplied predicate.
Declaration
export declare function filterBy<T, K>(source: Iterable<T>, keySelector: (element: T) => K, predicate: (key: K, offset: number) => boolean): Iterable<T>;
Type Parameters
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for each element.
- predicate
- (key: K, offset: number) => boolean
A callback used to match each key. Subquery
Returns
filterDefined(source)
Creates an Iterable
whose elements are neither null
nor undefined
.
Declaration
export declare function filterDefined<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>): HierarchyIterable<TNode, NonNullable<T>>;
Type Parameters
- TNode
- T
Parameters
Returns
filterDefined(source)
Creates an Iterable
whose elements are neither null
nor undefined
.
Declaration
export declare function filterDefined<T>(source: Iterable<T>): Iterable<NonNullable<T>>;
Type Parameters
- T
Parameters
Returns
filterDefinedBy(source, keySelector)
Creates an Iterable
where the selected key for each element is neither null
nor undefined
.
Declaration
export declare function filterDefinedBy<TNode, T extends TNode, K>(source: HierarchyIterable<TNode, T>, keySelector: (value: T) => K): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
- K
Parameters
- keySelector
- (value: T) => K
A callback used to select the key for each element. Subquery
Returns
filterDefinedBy(source, keySelector)
Creates an Iterable
where the selected key for each element is neither null
nor undefined
.
Declaration
export declare function filterDefinedBy<T, K>(source: Iterable<T>, keySelector: (value: T) => K): Iterable<T>;
Type Parameters
- T
- K
Parameters
- keySelector
- (value: T) => K
A callback used to select the key for each element. Subquery
Returns
filterNot(source, predicate)
Creates an Iterable
whose elements do not match the supplied predicate.
Declaration
export declare function filterNot<TNode, T extends TNode, U extends T>(source: HierarchyIterable<TNode, T>, predicate: (element: T, offset: number) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- T
- U
Parameters
- predicate
- (element: T, offset: number) => element is U
A callback used to match each element. Subquery
Returns
filterNot(source, predicate)
Creates an Iterable
whose elements do not match the supplied predicate.
Declaration
export declare function filterNot<T, U extends T>(source: Iterable<T>, predicate: (element: T, offset: number) => element is U): Iterable<U>;
Type Parameters
- T
- U
Parameters
- predicate
- (element: T, offset: number) => element is U
A callback used to match each element. Subquery
Returns
filterNot(source, predicate)
Creates an Iterable
whose elements do not match the supplied predicate.
Declaration
export declare function filterNot<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, predicate: (element: T, offset: number) => boolean): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- predicate
- (element: T, offset: number) => boolean
A callback used to match each element. Subquery
Returns
filterNot(source, predicate)
Creates an Iterable
whose elements do not match the supplied predicate.
Declaration
export declare function filterNot<T>(source: Iterable<T>, predicate: (element: T, offset: number) => boolean): Iterable<T>;
Type Parameters
- T
Parameters
- predicate
- (element: T, offset: number) => boolean
A callback used to match each element. Subquery
Returns
filterNotBy(source, keySelector, predicate)
Creates an Iterable
where the selected key for each element does not match the supplied predicate.
Declaration
export declare function filterNotBy<TNode, T extends TNode, K>(source: HierarchyIterable<TNode, T>, keySelector: (element: T) => K, predicate: (key: K, offset: number) => boolean): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for each element.
- predicate
- (key: K, offset: number) => boolean
A callback used to match each key. Subquery
Returns
filterNotBy(source, keySelector, predicate)
Creates an Iterable
where the selected key for each element does not match the supplied predicate.
Declaration
export declare function filterNotBy<T, K>(source: Iterable<T>, keySelector: (element: T) => K, predicate: (key: K, offset: number) => boolean): Iterable<T>;
Type Parameters
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for each element.
- predicate
- (key: K, offset: number) => boolean
A callback used to match each key. Subquery
Returns
filterNotDefinedBy(source, keySelector)
Creates an Iterable
where the selected key for each element is either null
or undefined
.
Declaration
export declare function filterNotDefinedBy<TNode, T extends TNode, K>(source: HierarchyIterable<TNode, T>, keySelector: (value: T) => K): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
- K
Parameters
- keySelector
- (value: T) => K
A callback used to select the key for each element. Subquery
Returns
filterNotDefinedBy(source, keySelector)
Creates an Iterable
where the selected key for each element is either null
or undefined
.
Declaration
export declare function filterNotDefinedBy<T, K>(source: Iterable<T>, keySelector: (value: T) => K): Iterable<T>;
Type Parameters
- T
- K
Parameters
- keySelector
- (value: T) => K
A callback used to select the key for each element. Subquery
Returns
first(source, predicate)
Gets the first element, optionally filtering elements using the supplied callback.
Declaration
export declare function first<T, U extends T>(source: Iterable<T>, predicate: (element: T) => element is U): U | undefined;
Type Parameters
- T
- U
Parameters
- predicate
- (element: T) => element is U
An optional callback used to match each element. Scalar
Returns
first(source, predicate)
Gets the first element, optionally filtering elements using the supplied callback.
Declaration
export declare function first<T>(source: Iterable<T>, predicate?: (element: T) => boolean): T | undefined;
Type Parameters
- T
Parameters
- predicate
- (element: T) => boolean
An optional callback used to match each element. Scalar
Returns
firstChild(source, predicate)
Selects the first child of each node in the iterable. This is equivalent to the child::*[first()]
selector in XPath, or the :first-child
pseudo class in CSS.
Hierarchy
Declaration
export declare function firstChild<TNode, U extends TNode>(source: HierarchyIterable<TNode>, predicate: (element: TNode) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- U
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => element is U
Returns
firstChild(source, predicate)
Declaration
export declare function firstChild<TNode>(source: HierarchyIterable<TNode>, predicate?: (element: TNode) => boolean): HierarchyIterable<TNode>;
Type Parameters
- TNode
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => boolean
Returns
flatMap(source, projection)
Creates an Iterable
that iterates the results of applying a callback to each element of source
.
Declaration
export declare function flatMap<T, U>(source: Iterable<T>, projection: (element: T) => Iterable<U>): Iterable<U>;
Type Parameters
- T
- U
Parameters
- projection
- (element: T) => Iterable<U>
A callback used to map each element into an iterable. Subquery
Returns
flatMap(source, projection, resultSelector)
Creates an Iterable
that iterates the results of applying a callback to each element of source
.
Declaration
export declare function flatMap<T, U, R>(source: Iterable<T>, projection: (element: T) => Iterable<U>, resultSelector: (element: T, innerElement: U) => R): Iterable<R>;
Type Parameters
- T
- U
- R
Parameters
- resultSelector
- (element: T, innerElement: U) => R
A callback used to map an element and one of its projected values into a result. Subquery
Returns
following(source, predicate)
Selects the nodes that follow each node in the iterable. This is equivalent to the following-sibling::*
selector in XPath or the ~
combinator in CSS.
Hierarchy
Declaration
export declare function following<TNode, U extends TNode>(source: HierarchyIterable<TNode>, predicate: (element: TNode) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- U
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => element is U
Returns
following(source, predicate)
Declaration
export declare function following<TNode>(source: HierarchyIterable<TNode>, predicate?: (element: TNode) => boolean): HierarchyIterable<TNode>;
Type Parameters
- TNode
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => boolean
Returns
followingSiblings(source, predicate)
Selects the siblings that follow each node in the iterable. This is equivalent to the following-sibling::*
selector in XPath or the ~
combinator in CSS.
Hierarchy
Declaration
export declare function followingSiblings<TNode, U extends TNode>(source: HierarchyIterable<TNode>, predicate: (element: TNode) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- U
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => element is U
Returns
followingSiblings(source, predicate)
Declaration
export declare function followingSiblings<TNode>(source: HierarchyIterable<TNode>, predicate?: (element: TNode) => boolean): HierarchyIterable<TNode>;
Type Parameters
- TNode
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => boolean
Returns
forEach(source, callback)
Invokes a callback for each element of source
.
Declaration
export declare function forEach<T>(source: Iterable<T>, callback: (element: T, offset: number) => void): void;
Type Parameters
- T
Parameters
- callback
- (element: T, offset: number) => void
The callback to invoke. Scalar
Returns
fullJoin(outer, inner, outerKeySelector, innerKeySelector, resultSelector, keyEqualer)
Creates an Iterable
for the correlated elements between an outer Iterable
object and an inner
Iterable
object.
Declaration
export declare function fullJoin<O, I, K, R>(outer: Iterable<O>, inner: Iterable<I>, outerKeySelector: (element: O) => K, innerKeySelector: (element: I) => K, resultSelector: (outer: O | undefined, inner: I | undefined) => R, keyEqualer?: Equaler<K>): Iterable<R>;
Type Parameters
- O
- I
- K
- R
Parameters
- outerKeySelector
- (element: O) => K
A callback used to select the key for an element in outer
.
- innerKeySelector
- (element: I) => K
A callback used to select the key for an element in inner
.
- resultSelector
- (outer: O | undefined, inner: I | undefined) => R
A callback used to select the result for the correlated elements.
Returns
generate(count, generator)
Creates an Iterable
whose values are provided by a callback executed a provided number of
times.
Declaration
export declare function generate<T>(count: number, generator: (offset: number) => T): Iterable<T>;
Type Parameters
- T
Parameters
- generator
- (offset: number) => T
The callback to execute. Query
Returns
groupBy(source, keySelector, keyEqualer)
Groups each element of an Iterable
by its key.
Declaration
export declare function groupBy<TNode, T extends TNode, K>(source: HierarchyIterable<TNode, T>, keySelector: (element: T) => K, keyEqualer?: Equaler<K>): Iterable<HierarchyGrouping<K, TNode, T>>;
Type Parameters
- TNode
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for an element.
Returns
groupBy(source, keySelector, elementSelector, resultSelector, keyEqualer)
Groups each element of an Iterable
by its key.
Declaration
export declare function groupBy<TNode, T extends TNode, K, R>(source: HierarchyIterable<TNode, T>, keySelector: (element: T) => K, elementSelector: undefined, resultSelector: (key: K, elements: HierarchyIterable<TNode, T>) => R, keyEqualer?: Equaler<K>): Iterable<R>;
Type Parameters
- TNode
- T
- K
- R
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for an element.
- resultSelector
- (key: K, elements: HierarchyIterable<TNode, T>) => R
A callback used to select a result from a group.
Returns
groupBy(source, keySelector, keyEqualer)
Groups each element of an Iterable
by its key.
Declaration
export declare function groupBy<T, K>(source: Iterable<T>, keySelector: (element: T) => K, keyEqualer?: Equaler<K>): Iterable<Grouping<K, T>>;
Type Parameters
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for an element.
Returns
groupBy(source, keySelector, elementSelector, keyEqualer)
Groups each element of an Iterable
by its key.
Declaration
export declare function groupBy<T, K, V>(source: Iterable<T>, keySelector: (element: T) => K, elementSelector: (element: T) => V, keyEqualer?: Equaler<K>): Iterable<Grouping<K, V>>;
Type Parameters
- T
- K
- V
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for an element.
- elementSelector
- (element: T) => V
A callback used to select a value for an element.
Returns
groupBy(source, keySelector, elementSelector, resultSelector, keyEqualer)
Groups each element of an Iterable
by its key.
Declaration
export declare function groupBy<T, K, V, R>(source: Iterable<T>, keySelector: (element: T) => K, elementSelector: (element: T) => V, resultSelector: (key: K, elements: Iterable<V>) => R, keyEqualer?: Equaler<K>): Iterable<R>;
Type Parameters
- T
- K
- V
- R
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for an element.
- elementSelector
- (element: T) => V
A callback used to select a value for an element.
- resultSelector
- (key: K, elements: Iterable<V>) => R
A callback used to select a result from a group.
Returns
groupJoin(outer, inner, outerKeySelector, innerKeySelector, resultSelector, keyEqualer)
Creates a grouped Iterable
for the correlated elements between an outer Iterable
object and an inner Iterable
object.
Declaration
export declare function groupJoin<O, I, K, R>(outer: Iterable<O>, inner: Iterable<I>, outerKeySelector: (element: O) => K, innerKeySelector: (element: I) => K, resultSelector: (outer: O, inner: Iterable<I>) => R, keyEqualer?: Equaler<K>): Iterable<R>;
Type Parameters
- O
- I
- K
- R
Parameters
- outerKeySelector
- (element: O) => K
A callback used to select the key for an element in outer
.
- innerKeySelector
- (element: I) => K
A callback used to select the key for an element in inner
.
- resultSelector
- (outer: O, inner: Iterable<I>) => R
A callback used to select the result for the correlated elements.
Returns
includes(source, value, equaler)
Computes a scalar value indicating whether the provided value is included in an Iterable
.
Declaration
export declare function includes<T>(source: Iterable<T>, value: T, equaler?: EqualityComparison<T> | Equaler<T>): boolean;
Type Parameters
- T
Parameters
- value
- T
A value.
- equaler
- EqualityComparison<T> | Equaler<T>
An optional callback used to compare the equality of two elements. Scalar
Returns
includes(source, value, equaler)
Computes a scalar value indicating whether the provided value is included in an Iterable
.
Declaration
export declare function includes<T, U>(source: Iterable<T>, value: U, equaler: (left: T, right: U) => boolean): boolean;
Type Parameters
- T
- U
Parameters
- value
- U
A value.
- equaler
- (left: T, right: U) => boolean
An optional callback used to compare the equality of two elements. Scalar
Returns
includesSequence(left, right, equaler)
Computes a scalar value indicating whether the elements of left
include
an exact sequence of elements from right
.
Declaration
export declare function includesSequence<T>(left: Iterable<T>, right: Iterable<T>, equaler?: EqualityComparison<T> | Equaler<T>): boolean;
Type Parameters
- T
Parameters
- equaler
- EqualityComparison<T> | Equaler<T>
A callback used to compare the equality of two elements. Scalar
Returns
includesSequence(left, right, equaler)
Computes a scalar value indicating whether the elements of left
include
an exact sequence of elements from right
.
Declaration
export declare function includesSequence<T, U>(left: Iterable<T>, right: Iterable<U>, equaler: (left: T, right: U) => boolean): boolean;
Type Parameters
- T
- U
Parameters
- equaler
- (left: T, right: U) => boolean
A callback used to compare the equality of two elements. Scalar
Returns
intersect(left, right, equaler)
Creates an Iterable
for the set intersection of two Iterable
objects.
Declaration
export declare function intersect<TNode, T extends TNode>(left: HierarchyIterable<TNode, T>, right: Iterable<T>, equaler?: Equaler<T>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
Returns
intersect(left, right, equaler)
Creates an Iterable
for the set intersection of two Iterable
objects.
Declaration
export declare function intersect<TNode, T extends TNode>(left: Iterable<T>, right: HierarchyIterable<TNode, T>, equaler?: Equaler<T>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
Returns
intersect(left, right, equaler)
Creates an Iterable
for the set intersection of two Iterable
objects.
Declaration
export declare function intersect<T>(left: Iterable<T>, right: Iterable<T>, equaler?: Equaler<T>): Iterable<T>;
Type Parameters
- T
Parameters
Returns
intersectBy(left, right, keySelector, keyEqualer)
Creates an Iterable
for the set intersection of two Iterable
objects, where set identity is determined by the selected key.
Declaration
export declare function intersectBy<TNode, T extends TNode, K>(left: HierarchyIterable<TNode, T>, right: Iterable<T>, keySelector: (element: T) => K, keyEqualer?: Equaler<K>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for each element.
Returns
intersectBy(left, right, keySelector, keyEqualer)
Creates an Iterable
for the set intersection of two Iterable
objects, where set identity is determined by the selected key.
Declaration
export declare function intersectBy<TNode, T extends TNode, K>(left: Iterable<T>, right: HierarchyIterable<TNode, T>, keySelector: (element: T) => K, keyEqualer?: Equaler<K>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for each element.
Returns
intersectBy(left, right, keySelector, keyEqualer)
Creates an Iterable
for the set intersection of two Iterable
objects, where set identity is determined by the selected key.
Declaration
export declare function intersectBy<T, K>(left: Iterable<T>, right: Iterable<T>, keySelector: (element: T) => K, keyEqualer?: Equaler<K>): Iterable<T>;
Type Parameters
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for each element.
Returns
into(source, callback)
Pass the entire source to the provided callback, returning a scalar result. Useful as the last step in a query.
Declaration
export declare function into<T, S extends Iterable<T>, R>(source: S, callback: (source: S) => R): R;
Type Parameters
- T
- S
- R
Parameters
- source
- S
An Iterable
object.
- callback
- (source: S) => R
A callback function. Subquery
Returns
join(outer, inner, outerKeySelector, innerKeySelector, resultSelector, keyEqualer)
Creates an Iterable
for the correlated elements of two Iterable
objects.
Declaration
export declare function join<O, I, K, R>(outer: Iterable<O>, inner: Iterable<I>, outerKeySelector: (element: O) => K, innerKeySelector: (element: I) => K, resultSelector: (outer: O, inner: I) => R, keyEqualer?: Equaler<K>): Iterable<R>;
Type Parameters
- O
- I
- K
- R
Parameters
- outerKeySelector
- (element: O) => K
A callback used to select the key for an element in outer
.
- innerKeySelector
- (element: I) => K
A callback used to select the key for an element in inner
.
- resultSelector
- (outer: O, inner: I) => R
A callback used to select the result for the correlated elements.
Returns
last(source, predicate)
Gets the last element of a Iterable
, optionally filtering elements using the supplied
callback.
Declaration
export declare function last<T, U extends T>(source: Iterable<T>, predicate: (element: T) => element is U): U | undefined;
Type Parameters
- T
- U
Parameters
- predicate
- (element: T) => element is U
An optional callback used to match each element. Scalar
Returns
last(source, predicate)
Gets the last element of a Iterable
, optionally filtering elements using the supplied
callback.
Declaration
export declare function last<T>(source: Iterable<T>, predicate?: (element: T) => boolean): T | undefined;
Type Parameters
- T
Parameters
- predicate
- (element: T) => boolean
An optional callback used to match each element. Scalar
Returns
lastChild(source, predicate)
Selects the last child of each node in the iterable. This is equivalent to the child::*[last()]
selector in XPath, or the :last-child
pseudo class in CSS.
Hierarchy
Declaration
export declare function lastChild<TNode, U extends TNode>(source: HierarchyIterable<TNode>, predicate: (element: TNode) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- U
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => element is U
Returns
lastChild(source, predicate)
Declaration
export declare function lastChild<TNode>(source: HierarchyIterable<TNode>, predicate?: (element: TNode) => boolean): HierarchyIterable<TNode>;
Type Parameters
- TNode
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => boolean
Returns
map(source, selector)
Creates an Iterable
by applying a callback to each element of a Iterable
.
Declaration
export declare function map<T, U>(source: Iterable<T>, selector: (element: T, offset: number) => U): Iterable<U>;
Type Parameters
- T
- U
Parameters
- selector
- (element: T, offset: number) => U
A callback used to map each element. Subquery
Returns
materialize(source)
Eagerly evaluate the Iterable
, returning a new Iterable
.
Subquery
Declaration
export declare function materialize<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- source
- HierarchyIterable<TNode, T>
Returns
materialize(source)
Declaration
export declare function materialize<T>(source: Iterable<T>): Iterable<T>;
Type Parameters
- T
Parameters
- source
- Iterable<T>
Returns
max(source, comparer)
Gets the maximum element of a Iterable
, optionally comparing elements using the supplied callback.
Declaration
export declare function max<T>(source: Iterable<T>, comparer?: Comparison<T> | Comparer<T>): T | undefined;
Type Parameters
- T
Parameters
Returns
maxBy(source, keySelector, keyComparer)
Gets the maximum element of a Iterable
, optionally comparing the keys of each element using the supplied callback.
Declaration
export declare function maxBy<T, K>(source: Iterable<T>, keySelector: (value: T) => K, keyComparer?: Comparison<K> | Comparer<K>): T | undefined;
Type Parameters
- T
- K
Parameters
- keySelector
- (value: T) => K
A callback used to choose the key to compare.
Returns
min(source, comparer)
Gets the minimum element of a Iterable
, optionally comparing elements using the supplied callback.
Declaration
export declare function min<T>(source: Iterable<T>, comparer?: Comparison<T> | Comparer<T>): T | undefined;
Type Parameters
- T
Parameters
Returns
minBy(source, keySelector, keyComparer)
Gets the minimum element of a Iterable
, optionally comparing the keys of each element using the supplied callback.
Declaration
export declare function minBy<T, K>(source: Iterable<T>, keySelector: (value: T) => K, keyComparer?: Comparison<K> | Comparer<K>): T | undefined;
Type Parameters
- T
- K
Parameters
- keySelector
- (value: T) => K
A callback used to choose the key to compare.
Returns
nthChild(source, offset, predicate)
Creates a HierarchyIterable
for the child of each element at the specified offset. A negative offset
starts from the last child. This is equivalent to the :nth-child()
pseudo-class in CSS.
Declaration
export declare function nthChild<TNode, U extends TNode>(source: HierarchyIterable<TNode>, offset: number, predicate: (element: TNode) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- U
Parameters
- predicate
- (element: TNode) => element is U
An optional callback used to filter the results. Hierarchy
Returns
nthChild(source, offset, predicate)
Declaration
export declare function nthChild<TNode>(source: HierarchyIterable<TNode>, offset: number, predicate?: (element: TNode) => boolean): HierarchyIterable<TNode>;
Type Parameters
- TNode
Parameters
- source
- HierarchyIterable<TNode>
- offset
- number
- predicate
- (element: TNode) => boolean
Returns
once(value)
Creates an Iterable
over a single element.
Declaration
export declare function once<T>(value: T): Iterable<T>;
Type Parameters
- T
Parameters
- value
- T
The only element for the Iterable
.
Query
Returns
orderBy(source, keySelector, keyComparer)
Creates an OrderedIterable
whose elements are sorted in ascending order by the provided key.
Declaration
export declare function orderBy<TNode, T extends TNode, K>(source: HierarchyIterable<TNode, T>, keySelector: (element: T) => K, keyComparer?: Comparison<K> | Comparer<K>): OrderedHierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for an element.
Returns
orderBy(source, keySelector, keyComparer)
Creates an OrderedIterable
whose elements are sorted in ascending order by the provided key.
Declaration
export declare function orderBy<T, K>(source: Iterable<T>, keySelector: (element: T) => K, keyComparer?: Comparison<K> | Comparer<K>): OrderedIterable<T>;
Type Parameters
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for an element.
Returns
orderByDescending(source, keySelector, keyComparer)
Creates an OrderedIterable
whose elements are sorted in descending order by the provided key.
Declaration
export declare function orderByDescending<TNode, T extends TNode, K>(source: HierarchyIterable<TNode, T>, keySelector: (element: T) => K, keyComparer?: Comparison<K> | Comparer<K>): OrderedHierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for an element.
Returns
orderByDescending(source, keySelector, keyComparer)
Creates an OrderedIterable
whose elements are sorted in descending order by the provided key.
Declaration
export declare function orderByDescending<T, K>(source: Iterable<T>, keySelector: (element: T) => K, keyComparer?: Comparison<K> | Comparer<K>): OrderedIterable<T>;
Type Parameters
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for an element.
Returns
pageBy(source, pageSize)
Creates an Iterable
that splits an Iterable
into one or more pages.
While advancing from page to page is evaluated lazily, the elements of the page are
evaluated eagerly.
Declaration
export declare function pageBy<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, pageSize: number): Iterable<HierarchyPage<TNode, T>>;
Type Parameters
- TNode
- T
Parameters
Returns
pageBy(source, pageSize, pageSelector)
Creates an Iterable
that splits an Iterable
into one or more pages.
While advancing from page to page is evaluated lazily, the elements of the page are
evaluated eagerly.
Declaration
export declare function pageBy<TNode, T extends TNode, R>(source: HierarchyIterable<TNode, T>, pageSize: number, pageSelector: (page: number, offset: number, values: HierarchyIterable<TNode, T>) => R): Iterable<R>;
Type Parameters
- TNode
- T
- R
Parameters
- pageSelector
- (page: number, offset: number, values: HierarchyIterable<TNode, T>) => R
A callback used to create a result for a page. Subquery
Returns
pageBy(source, pageSize)
Creates an Iterable
that splits an Iterable
into one or more pages.
While advancing from page to page is evaluated lazily, the elements of the page are
evaluated eagerly.
Declaration
export declare function pageBy<T>(source: Iterable<T>, pageSize: number): Iterable<Page<T>>;
Type Parameters
- T
Parameters
Returns
pageBy(source, pageSize, pageSelector)
Creates an Iterable
that splits an Iterable
into one or more pages.
While advancing from page to page is evaluated lazily, the elements of the page are
evaluated eagerly.
Declaration
export declare function pageBy<T, R>(source: Iterable<T>, pageSize: number, pageSelector: (page: number, offset: number, values: Iterable<T>) => R): Iterable<R>;
Type Parameters
- T
- R
Parameters
- pageSelector
- (page: number, offset: number, values: Iterable<T>) => R
A callback used to create a result for a page. Subquery
Returns
parents(source, predicate)
Selects the parent of each node in the iterable. This is equivalent to the parent::*
or ..
selectors in XPath.
Hierarchy
Declaration
export declare function parents<TNode, U extends TNode>(source: HierarchyIterable<TNode>, predicate: (element: TNode) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- U
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => element is U
Returns
parents(source, predicate)
Declaration
export declare function parents<TNode>(source: HierarchyIterable<TNode>, predicate?: (element: TNode) => boolean): HierarchyIterable<TNode>;
Type Parameters
- TNode
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => boolean
Returns
patch(source, start, skipCount, range)
Creates an Iterable
for the elements of source
with the provided range
patched into the results.
Declaration
export declare function patch<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, start: number, skipCount?: number, range?: Iterable<T>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
Returns
patch(source, start, skipCount, range)
Creates an Iterable
for the elements of source
with the provided range
patched into the results.
Declaration
export declare function patch<T>(source: Iterable<T>, start: number, skipCount?: number, range?: Iterable<T>): Iterable<T>;
Type Parameters
- T
Parameters
Returns
preceding(source, predicate)
Selects the nodes that precede each node in the iterable. This is equivalent to the preceding::**
selector in XPath.
Hierarchy
Declaration
export declare function preceding<TNode, U extends TNode>(source: HierarchyIterable<TNode>, predicate: (element: TNode) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- U
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => element is U
Returns
preceding(source, predicate)
Declaration
export declare function preceding<TNode>(source: HierarchyIterable<TNode>, predicate?: (element: TNode) => boolean): HierarchyIterable<TNode>;
Type Parameters
- TNode
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => boolean
Returns
precedingSiblings(source, predicate)
Selects the siblings that precede each node in the iterable. This is equivalent to the preceding-sibling::**
selector in XPath.
Hierarchy
Declaration
export declare function precedingSiblings<TNode, U extends TNode>(source: HierarchyIterable<TNode>, predicate: (element: TNode) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- U
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => element is U
Returns
precedingSiblings(source, predicate)
Declaration
export declare function precedingSiblings<TNode>(source: HierarchyIterable<TNode>, predicate?: (element: TNode) => boolean): HierarchyIterable<TNode>;
Type Parameters
- TNode
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => boolean
Returns
prepend(source, value)
Creates a subquery for the elements of the source with the provided value prepended to the beginning.
Declaration
export declare function prepend<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, value: T): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- source
- HierarchyIterable<TNode, T>
- value
- T
The value to prepend. Subquery
Returns
prepend(source, value)
Creates a subquery for the elements of the source with the provided value prepended to the beginning.
Declaration
export declare function prepend<T>(source: Iterable<T>, value: T): Iterable<T>;
Type Parameters
- T
Parameters
- source
- Iterable<T>
- value
- T
The value to prepend. Subquery
Returns
range(start, end, increment)
Creates an Iterable
over a range of numbers.
Declaration
export declare function range(start: number, end: number, increment?: number): Iterable<number>;
Parameters
Returns
reduce(source, accumulator)
Computes a scalar value by applying an accumulator callback over each element.
Declaration
export declare function reduce<T>(source: Iterable<T>, accumulator: (current: T, element: T, offset: number) => T): T;
Type Parameters
- T
Parameters
- accumulator
- (current: T, element: T, offset: number) => T
the callback used to compute the result. Scalar
Returns
reduce(source, accumulator, seed, resultSelector)
Computes a scalar value by applying an accumulator callback over each element.
Declaration
export declare function reduce<T, U>(source: Iterable<T>, accumulator: (current: U, element: T, offset: number) => U, seed: U, resultSelector?: (result: U, count: number) => U): U;
Type Parameters
- T
- U
Parameters
- accumulator
- (current: U, element: T, offset: number) => U
the callback used to compute the result.
- seed
- U
An optional seed value. Scalar
- resultSelector
- (result: U, count: number) => U
Returns
reduce(source, accumulator, seed, resultSelector)
Computes a scalar value by applying an accumulator callback over each element.
Declaration
export declare function reduce<T, U, R>(source: Iterable<T>, accumulator: (current: U, element: T, offset: number) => U, seed: U, resultSelector: (result: U, count: number) => R): R;
Type Parameters
- T
- U
- R
Parameters
- accumulator
- (current: U, element: T, offset: number) => U
the callback used to compute the result.
- seed
- U
An optional seed value.
- resultSelector
- (result: U, count: number) => R
An optional callback used to compute the final result. Scalar
Returns
reduceRight(source, accumulator)
Computes a scalar value by applying an accumulator callback over each element in reverse.
Declaration
export declare function reduceRight<T>(source: Iterable<T>, accumulator: (current: T, element: T, offset: number) => T): T;
Type Parameters
- T
Parameters
- accumulator
- (current: T, element: T, offset: number) => T
the callback used to compute the result. Scalar
Returns
reduceRight(source, accumulator, seed, resultSelector)
Computes a scalar value by applying an accumulator callback over each element in reverse.
Declaration
export declare function reduceRight<T, U>(source: Iterable<T>, accumulator: (current: U, element: T, offset: number) => U, seed: U, resultSelector?: (result: U, count: number) => U): U;
Type Parameters
- T
- U
Parameters
- accumulator
- (current: U, element: T, offset: number) => U
the callback used to compute the result.
- seed
- U
An optional seed value. Scalar
- resultSelector
- (result: U, count: number) => U
Returns
reduceRight(source, accumulator, seed, resultSelector)
Computes a scalar value by applying an accumulator callback over each element in reverse.
Declaration
export declare function reduceRight<T, U, R>(source: Iterable<T>, accumulator: (current: U, element: T, offset: number) => U, seed: U, resultSelector: (result: U, count: number) => R): R;
Type Parameters
- T
- U
- R
Parameters
- accumulator
- (current: U, element: T, offset: number) => U
the callback used to compute the result.
- seed
- U
An optional seed value.
- resultSelector
- (result: U, count: number) => R
An optional callback used to compute the final result. Scalar
Returns
repeat(value, count)
Creates an Iterable for a value repeated a provided number of times.
Declaration
export declare function repeat<T>(value: T, count: number): Iterable<T>;
Type Parameters
- T
Parameters
- value
- T
The value for each element of the Iterable.
Returns
reverse(source)
Creates a subquery whose elements are in the reverse order. Ordering
Declaration
export declare function reverse<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- source
- HierarchyIterable<TNode, T>
Returns
reverse(source)
Creates a subquery whose elements are in the reverse order. Ordering
Declaration
export declare function reverse<T>(source: Iterable<T>): Iterable<T>;
Type Parameters
- T
Parameters
- source
- Iterable<T>
Returns
root(source, predicate)
Selects the root element of each node in the iterable. This is equivalent to the /
selector in XPath, or the :root
selector in CSS.
Hierarchy
Declaration
export declare function root<TNode, U extends TNode>(source: HierarchyIterable<TNode>, predicate: (element: TNode) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- U
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => element is U
Returns
root(source, predicate)
Declaration
export declare function root<TNode>(source: HierarchyIterable<TNode>, predicate?: (element: TNode) => boolean): HierarchyIterable<TNode>;
Type Parameters
- TNode
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => boolean
Returns
scan(source, accumulator)
Creates a subquery containing the cumulative results of applying the provided callback to each element.
Declaration
export declare function scan<T>(source: Iterable<T>, accumulator: (current: T, element: T, offset: number) => T): Iterable<T>;
Type Parameters
- T
Parameters
- accumulator
- (current: T, element: T, offset: number) => T
The callback used to compute each result. Subquery
Returns
scan(source, accumulator, seed)
Creates a subquery containing the cumulative results of applying the provided callback to each element.
Declaration
export declare function scan<T, U>(source: Iterable<T>, accumulator: (current: U, element: T, offset: number) => U, seed: U): Iterable<U>;
Type Parameters
- T
- U
Parameters
- accumulator
- (current: U, element: T, offset: number) => U
The callback used to compute each result.
- seed
- U
An optional seed value. Subquery
Returns
scanRight(source, accumulator)
Creates a subquery containing the cumulative results of applying the provided callback to each element in reverse.
Declaration
export declare function scanRight<T>(source: Iterable<T>, accumulator: (current: T, element: T, offset: number) => T): Iterable<T>;
Type Parameters
- T
Parameters
- accumulator
- (current: T, element: T, offset: number) => T
The callback used to compute each result. Subquery
Returns
scanRight(source, accumulator, seed)
Creates a subquery containing the cumulative results of applying the provided callback to each element in reverse.
Declaration
export declare function scanRight<T, U>(source: Iterable<T>, accumulator: (current: U, element: T, offset: number) => U, seed: U): Iterable<U>;
Type Parameters
- T
- U
Parameters
- accumulator
- (current: U, element: T, offset: number) => U
The callback used to compute each result.
- seed
- U
An optional seed value. Subquery
Returns
self(source, predicate)
Selects each node in the iterable. This is equivalent to the self::*
or .
selectors in XPath.
Hierarchy
Declaration
export declare function self<TNode, T extends TNode, U extends T>(source: HierarchyIterable<TNode, T>, predicate: (element: T) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- T
- U
Parameters
- source
- HierarchyIterable<TNode, T>
- predicate
- (element: T) => element is U
Returns
self(source, predicate)
Declaration
export declare function self<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, predicate?: (element: T) => boolean): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- source
- HierarchyIterable<TNode, T>
- predicate
- (element: T) => boolean
Returns
siblings(source, predicate)
Selects the siblings of each node in the iterable, excluding the node itself. Hierarchy
Declaration
export declare function siblings<TNode, U extends TNode>(source: HierarchyIterable<TNode>, predicate: (element: TNode) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- U
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => element is U
Returns
siblings(source, predicate)
Declaration
export declare function siblings<TNode>(source: HierarchyIterable<TNode>, predicate?: (element: TNode) => boolean): HierarchyIterable<TNode>;
Type Parameters
- TNode
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => boolean
Returns
siblingsAndSelf(source, predicate)
Selects the siblings of each node in the iterable, including the node itself. This equivalent to the ../*
selector in XPath.
Hierarchy
Declaration
export declare function siblingsAndSelf<TNode, U extends TNode>(source: HierarchyIterable<TNode>, predicate: (element: TNode) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- U
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => element is U
Returns
siblingsAndSelf(source, predicate)
Declaration
export declare function siblingsAndSelf<TNode>(source: HierarchyIterable<TNode>, predicate?: (element: TNode) => boolean): HierarchyIterable<TNode>;
Type Parameters
- TNode
Parameters
- source
- HierarchyIterable<TNode>
- predicate
- (element: TNode) => boolean
Returns
single(source, predicate)
Gets the only element, or returns undefined
.
Declaration
export declare function single<T, U extends T>(source: Iterable<T>, predicate: (element: T) => element is U): U | undefined;
Type Parameters
- T
- U
Parameters
- predicate
- (element: T) => element is U
An optional callback used to match each element. Scalar
Returns
single(source, predicate)
Gets the only element, or returns undefined
.
Declaration
export declare function single<T>(source: Iterable<T>, predicate?: (element: T) => boolean): T | undefined;
Type Parameters
- T
Parameters
- predicate
- (element: T) => boolean
An optional callback used to match each element. Scalar
Returns
some(source, predicate)
Computes a scalar value indicating whether source
contains any elements,
optionally filtering the elements using the supplied callback.
Declaration
export declare function some<T>(source: Iterable<T>, predicate?: (element: T) => boolean): boolean;
Type Parameters
- T
Parameters
- predicate
- (element: T) => boolean
An optional callback used to match each element. Scalar
Returns
span(source, predicate)
Creates a tuple whose first element is an Iterable
containing the first span of
elements that match the supplied predicate, and whose second element is an Iterable
containing the remaining elements.
The first Iterable
is eagerly evaluated, while the second Iterable
is lazily
evaluated.
Declaration
export declare function span<TNode, T extends TNode, U extends T>(source: HierarchyIterable<TNode, T>, predicate: (element: T, offset: number) => element is U): [HierarchyIterable<TNode, U>, HierarchyIterable<TNode, T>];
Type Parameters
- TNode
- T
- U
Parameters
- predicate
- (element: T, offset: number) => element is U
The predicate used to match elements. Scalar
Returns
span(source, predicate)
Creates a tuple whose first element is an Iterable
containing the first span of
elements that match the supplied predicate, and whose second element is an Iterable
containing the remaining elements.
The first Iterable
is eagerly evaluated, while the second Iterable
is lazily
evaluated.
Declaration
export declare function span<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, predicate: (element: T, offset: number) => boolean): [HierarchyIterable<TNode, T>, HierarchyIterable<TNode, T>];
Type Parameters
- TNode
- T
Parameters
- predicate
- (element: T, offset: number) => boolean
The predicate used to match elements. Scalar
Returns
span(source, predicate)
Creates a tuple whose first element is an Iterable
containing the first span of
elements that match the supplied predicate, and whose second element is an Iterable
containing the remaining elements.
The first Iterable
is eagerly evaluated, while the second Iterable
is lazily
evaluated.
Declaration
export declare function span<T, U extends T>(source: Iterable<T>, predicate: (element: T, offset: number) => element is U): [Iterable<U>, Iterable<T>];
Type Parameters
- T
- U
Parameters
- predicate
- (element: T, offset: number) => element is U
The predicate used to match elements. Scalar
Returns
span(source, predicate)
Creates a tuple whose first element is an Iterable
containing the first span of
elements that match the supplied predicate, and whose second element is an Iterable
containing the remaining elements.
The first Iterable
is eagerly evaluated, while the second Iterable
is lazily
evaluated.
Declaration
export declare function span<T>(source: Iterable<T>, predicate: (element: T, offset: number) => boolean): [Iterable<T>, Iterable<T>];
Type Parameters
- T
Parameters
- predicate
- (element: T, offset: number) => boolean
The predicate used to match elements. Scalar
Returns
spanMap(source, keySelector, keyEqualer)
Creates a subquery whose elements are the contiguous ranges of elements that share the same key.
Declaration
export declare function spanMap<TNode, T extends TNode, K>(source: HierarchyIterable<TNode, T>, keySelector: (element: T) => K, keyEqualer?: Equaler<K>): Iterable<HierarchyGrouping<K, TNode, T>>;
Type Parameters
- TNode
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for an element.
Returns
spanMap(source, keySelector, elementSelector, spanSelector, keyEqualer)
Creates a subquery whose elements are the contiguous ranges of elements that share the same key.
Declaration
export declare function spanMap<TNode, T extends TNode, K, R>(source: HierarchyIterable<TNode, T>, keySelector: (element: T) => K, elementSelector: undefined, spanSelector: (key: K, elements: HierarchyIterable<TNode, T>) => R, keyEqualer?: Equaler<K>): Iterable<R>;
Type Parameters
- TNode
- T
- K
- R
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for an element.
- spanSelector
- (key: K, elements: HierarchyIterable<TNode, T>) => R
A callback used to select a result from a contiguous range.
Returns
spanMap(source, keySelector, keyEqualer)
Creates a subquery whose elements are the contiguous ranges of elements that share the same key.
Declaration
export declare function spanMap<T, K>(source: Iterable<T>, keySelector: (element: T) => K, keyEqualer?: Equaler<K>): Iterable<Grouping<K, T>>;
Type Parameters
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for an element.
Returns
spanMap(source, keySelector, elementSelector, keyEqualer)
Creates a subquery whose values are computed from each element of the contiguous ranges of elements that share the same key.
Declaration
export declare function spanMap<T, K, V>(source: Iterable<T>, keySelector: (element: T) => K, elementSelector: (element: T) => V, keyEqualer?: Equaler<K>): Iterable<Grouping<K, V>>;
Type Parameters
- T
- K
- V
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for an element.
- elementSelector
- (element: T) => V
A callback used to select a value for an element.
Returns
spanMap(source, keySelector, elementSelector, spanSelector, keyEqualer)
Creates a subquery whose values are computed from the contiguous ranges of elements that share the same key.
Declaration
export declare function spanMap<T, K, V, R>(source: Iterable<T>, keySelector: (element: T) => K, elementSelector: (element: T) => V, spanSelector: (key: K, elements: Iterable<V>) => R, keyEqualer?: Equaler<K>): Iterable<R>;
Type Parameters
- T
- K
- V
- R
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for an element.
- elementSelector
- (element: T) => V
A callback used to select a value for an element.
- spanSelector
- (key: K, elements: Iterable<V>) => R
A callback used to select a result from a contiguous range.
Returns
spanUntil(source, predicate)
Creates a tuple whose first element is an Iterable
containing the first span of
elements that do not match the supplied predicate, and whose second element is an Iterable
containing the remaining elements.
The first Iterable
is eagerly evaluated, while the second Iterable
is lazily
evaluated.
Declaration
export declare function spanUntil<T>(source: HierarchyIterable<T>, predicate: (element: T, offset: number) => boolean): [HierarchyIterable<T>, HierarchyIterable<T>];
Type Parameters
- T
Parameters
- predicate
- (element: T, offset: number) => boolean
The predicate used to match elements. Scalar
Returns
spanUntil(source, predicate)
Creates a tuple whose first element is an Iterable
containing the first span of
elements that do not match the supplied predicate, and whose second element is an Iterable
containing the remaining elements.
The first Iterable
is eagerly evaluated, while the second Iterable
is lazily
evaluated.
Declaration
export declare function spanUntil<T>(source: Iterable<T>, predicate: (element: T, offset: number) => boolean): [Iterable<T>, Iterable<T>];
Type Parameters
- T
Parameters
- predicate
- (element: T, offset: number) => boolean
The predicate used to match elements. Scalar
Returns
startsWith(left, right, equaler)
Computes a scalar value indicating whether the elements of this Query start with the same sequence of elements in another Iterable.
Declaration
export declare function startsWith<T>(left: Iterable<T>, right: Iterable<T>, equaler?: EqualityComparison<T> | Equaler<T>): boolean;
Type Parameters
- T
Parameters
- equaler
- EqualityComparison<T> | Equaler<T>
A callback used to compare the equality of two elements. Scalar
Returns
startsWith(left, right, equaler)
Computes a scalar value indicating whether the elements of this Query start with the same sequence of elements in another Iterable.
Declaration
export declare function startsWith<T, U>(left: Iterable<T>, right: Iterable<U>, equaler: (left: T, right: U) => boolean): boolean;
Type Parameters
- T
- U
Parameters
- equaler
- (left: T, right: U) => boolean
A callback used to compare the equality of two elements. Scalar
Returns
sum(source)
Computes the sum for a series of numbers.
Declaration
export declare function sum(source: Iterable<number>): number;
Parameters
Returns
sum(source, elementSelector)
Computes the sum for a series of numbers.
Declaration
export declare function sum<T>(source: Iterable<T>, elementSelector: (element: T) => number): number;
Type Parameters
- T
Parameters
- elementSelector
- (element: T) => number
A callback used to convert a value in source
to a number.
Scalar
Returns
symmetricDifference(left, right, equaler)
Creates a subquery for the symmetric difference between two Iterable
objects.
The result is an Iterable
containings the elements that exist in only left or right, but not
in both.
Declaration
export declare function symmetricDifference<TNode, T extends TNode>(left: HierarchyIterable<TNode, T>, right: Iterable<T>, equaler?: Equaler<T>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
Returns
symmetricDifference(left, right, equaler)
Creates a subquery for the symmetric difference between two Iterable
objects.
The result is an Iterable
containings the elements that exist in only left or right, but not
in both.
Declaration
export declare function symmetricDifference<TNode, T extends TNode>(left: Iterable<T>, right: HierarchyIterable<TNode, T>, equaler?: Equaler<T>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
Returns
symmetricDifference(left, right, equaler)
Creates a subquery for the symmetric difference between two Iterable
objects.
The result is an Iterable
containings the elements that exist in only left or right, but not
in both.
Declaration
export declare function symmetricDifference<T>(left: Iterable<T>, right: Iterable<T>, equaler?: Equaler<T>): Iterable<T>;
Type Parameters
- T
Parameters
Returns
symmetricDifferenceBy(left, right, keySelector, keyEqualer)
Creates a subquery for the symmetric difference between two Iterable
objects, where set identity is determined by the selected key.
The result is an Iterable
containings the elements that exist in only left or right, but not
in both.
Declaration
export declare function symmetricDifferenceBy<TNode, T extends TNode, K>(left: HierarchyIterable<TNode, T>, right: Iterable<T>, keySelector: (element: T) => K, keyEqualer?: Equaler<K>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for each element.
Returns
symmetricDifferenceBy(left, right, keySelector, keyEqualer)
Creates a subquery for the symmetric difference between two Iterable
objects, where set identity is determined by the selected key.
The result is an Iterable
containings the elements that exist in only left or right, but not
in both.
Declaration
export declare function symmetricDifferenceBy<TNode, T extends TNode, K>(left: Iterable<T>, right: HierarchyIterable<TNode, T>, keySelector: (element: T) => K, keyEqualer?: Equaler<K>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for each element.
Returns
symmetricDifferenceBy(left, right, keySelector, keyEqualer)
Creates a subquery for the symmetric difference between two Iterable
objects, where set identity is determined by the selected key.
The result is an Iterable
containings the elements that exist in only left or right, but not
in both.
Declaration
export declare function symmetricDifferenceBy<T, K>(left: Iterable<T>, right: Iterable<T>, keySelector: (element: T) => K, keyEqualer?: Equaler<K>): Iterable<T>;
Type Parameters
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for each element.
Returns
take(source, count)
Creates a subquery containing the first elements up to the supplied count.
Declaration
export declare function take<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, count: number): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
Returns
take(source, count)
Creates a subquery containing the first elements up to the supplied count.
Declaration
export declare function take<T>(source: Iterable<T>, count: number): Iterable<T>;
Type Parameters
- T
Parameters
Returns
takeRight(source, count)
Creates a subquery containing the last elements up to the supplied count.
Declaration
export declare function takeRight<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, count: number): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
Returns
takeRight(source, count)
Creates a subquery containing the last elements up to the supplied count.
Declaration
export declare function takeRight<T>(source: Iterable<T>, count: number): Iterable<T>;
Type Parameters
- T
Parameters
Returns
takeUntil(source, predicate)
Creates a subquery containing the first elements that do not match the supplied predicate.
Declaration
export declare function takeUntil<TNode, T extends TNode, U extends T>(source: HierarchyIterable<TNode, T>, predicate: (element: T) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- T
- U
Parameters
- predicate
- (element: T) => element is U
A callback used to match each element. Subquery
Returns
takeUntil(source, predicate)
Creates a subquery containing the first elements that do not match the supplied predicate.
Declaration
export declare function takeUntil<T, U extends T>(source: Iterable<T>, predicate: (element: T) => element is U): Iterable<U>;
Type Parameters
- T
- U
Parameters
- predicate
- (element: T) => element is U
A callback used to match each element. Subquery
Returns
takeUntil(source, predicate)
Creates a subquery containing the first elements that do not match the supplied predicate.
Declaration
export declare function takeUntil<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, predicate: (element: T) => boolean): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- predicate
- (element: T) => boolean
A callback used to match each element. Subquery
Returns
takeUntil(source, predicate)
Creates a subquery containing the first elements that do not match the supplied predicate.
Declaration
export declare function takeUntil<T>(source: Iterable<T>, predicate: (element: T) => boolean): Iterable<T>;
Type Parameters
- T
Parameters
- predicate
- (element: T) => boolean
A callback used to match each element. Subquery
Returns
takeWhile(source, predicate)
Creates a subquery containing the first elements that match the supplied predicate.
Declaration
export declare function takeWhile<TNode, T extends TNode, U extends T>(source: HierarchyIterable<TNode, T>, predicate: (element: T) => element is U): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- T
- U
Parameters
- predicate
- (element: T) => element is U
A callback used to match each element. Subquery
Returns
takeWhile(source, predicate)
Creates a subquery containing the first elements that match the supplied predicate.
Declaration
export declare function takeWhile<T, U extends T>(source: Iterable<T>, predicate: (element: T) => element is U): Iterable<U>;
Type Parameters
- T
- U
Parameters
- predicate
- (element: T) => element is U
A callback used to match each element. Subquery
Returns
takeWhile(source, predicate)
Creates a subquery containing the first elements that match the supplied predicate.
Declaration
export declare function takeWhile<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, predicate: (element: T) => boolean): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- predicate
- (element: T) => boolean
A callback used to match each element. Subquery
Returns
takeWhile(source, predicate)
Creates a subquery containing the first elements that match the supplied predicate.
Declaration
export declare function takeWhile<T>(source: Iterable<T>, predicate: (element: T) => boolean): Iterable<T>;
Type Parameters
- T
Parameters
- predicate
- (element: T) => boolean
A callback used to match each element. Subquery
Returns
tap(source, callback)
Lazily invokes a callback as each element of the iterable is iterated.
Declaration
export declare function tap<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, callback: (element: T, offset: number) => void): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- callback
- (element: T, offset: number) => void
The callback to invoke. Subquery
Returns
tap(source, callback)
Lazily invokes a callback as each element of the iterable is iterated.
Declaration
export declare function tap<T>(source: Iterable<T>, callback: (element: T, offset: number) => void): Iterable<T>;
Type Parameters
- T
Parameters
- callback
- (element: T, offset: number) => void
The callback to invoke. Subquery
Returns
thenBy(source, keySelector, keyComparer)
Creates a subsequent OrderedIterable
whose elements are also sorted in ascending order by the provided key.
Declaration
export declare function thenBy<TNode, T extends TNode, K>(source: OrderedHierarchyIterable<TNode, T>, keySelector: (element: T) => K, keyComparer?: Comparison<K> | Comparer<K>): OrderedHierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for an element.
Returns
thenBy(source, keySelector, keyComparer)
Creates a subsequent OrderedIterable
whose elements are also sorted in ascending order by the provided key.
Declaration
export declare function thenBy<T, K>(source: OrderedIterable<T>, keySelector: (element: T) => K, keyComparer?: Comparison<K> | Comparer<K>): OrderedIterable<T>;
Type Parameters
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for an element.
Returns
thenByDescending(source, keySelector, keyComparer)
Creates a subsequent OrderedIterable
whose elements are also sorted in descending order by the provided key.
Declaration
export declare function thenByDescending<TNode, T extends TNode, K>(source: OrderedHierarchyIterable<TNode, T>, keySelector: (element: T) => K, keyComparer?: Comparison<K> | Comparer<K>): OrderedHierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for an element.
Returns
thenByDescending(source, keySelector, keyComparer)
Creates a subsequent OrderedIterable
whose elements are also sorted in descending order by the provided key.
Declaration
export declare function thenByDescending<T, K>(source: OrderedIterable<T>, keySelector: (element: T) => K, keyComparer?: Comparison<K> | Comparer<K>): OrderedIterable<T>;
Type Parameters
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for an element.
Returns
toArray(source)
Creates an Array for the elements of the Iterable
.
Declaration
export declare function toArray<T>(source: Iterable<T>): T[];
Type Parameters
- T
Parameters
Returns
toArray(source, elementSelector)
Creates an Array for the elements of the Iterable
.
Declaration
export declare function toArray<T, V>(source: Iterable<T>, elementSelector: (element: T) => V): V[];
Type Parameters
- T
- V
Parameters
- elementSelector
- (element: T) => V
A callback that selects a value for each element. Scalar
Returns
toHashMap(source, keySelector, keyEqualer)
Creates a HashMap for the elements of the Query.
Declaration
export declare function toHashMap<T, K>(source: Iterable<T>, keySelector: (element: T) => K, keyEqualer?: Equaler<K>): HashMap<K, T>;
Type Parameters
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select a key for each element.
Returns
toHashMap(source, keySelector, elementSelector, keyEqualer)
Creates a Map for the elements of the Query.
Declaration
export declare function toHashMap<T, K, V>(source: Iterable<T>, keySelector: (element: T) => K, elementSelector: (element: T) => V, keyEqualer?: Equaler<K>): HashMap<K, V>;
Type Parameters
- T
- K
- V
Parameters
- keySelector
- (element: T) => K
A callback used to select a key for each element.
- elementSelector
- (element: T) => V
A callback that selects a value for each element.
Returns
toHashSet(source, equaler)
Creates a HashSet for the elements of the Iterable.
Declaration
export declare function toHashSet<T>(source: Iterable<T>, equaler?: Equaler<T>): HashSet<T>;
Type Parameters
- T
Parameters
Returns
toHashSet(source, elementSelector, equaler)
Creates a Set for the elements of the Iterable.
Declaration
export declare function toHashSet<T, V>(source: Iterable<T>, elementSelector: (element: T) => V, equaler?: Equaler<V>): HashSet<V>;
Type Parameters
- T
- V
Parameters
- elementSelector
- (element: T) => V
A callback that selects a value for each element.
Returns
toHierarchy(iterable, provider)
Creates a HierarchyIterable
using the provided HierarchyProvider
.
Declaration
export declare function toHierarchy<TNode, T extends TNode = TNode>(iterable: OrderedIterable<T>, provider: HierarchyProvider<TNode>): OrderedHierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- iterable
- OrderedIterable<T>
- provider
- HierarchyProvider<TNode>
Returns
toHierarchy(iterable, provider)
Declaration
export declare function toHierarchy<TNode, T extends TNode = TNode>(iterable: Iterable<T>, provider: HierarchyProvider<TNode>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- iterable
- Iterable<T>
- provider
- HierarchyProvider<TNode>
Returns
toLookup(source, keySelector, keyEqualer)
Creates a Lookup for the elements of the Query.
Declaration
export declare function toLookup<T, K>(source: Iterable<T>, keySelector: (element: T) => K, keyEqualer?: Equaler<K>): Lookup<K, T>;
Type Parameters
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select a key for each element.
Returns
toLookup(source, keySelector, elementSelector, keyEqualer)
Creates a Lookup for the elements of the Query.
Declaration
export declare function toLookup<T, K, V>(source: Iterable<T>, keySelector: (element: T) => K, elementSelector: (element: T) => V, keyEqualer?: Equaler<K>): Lookup<K, V>;
Type Parameters
- T
- K
- V
Parameters
- keySelector
- (element: T) => K
A callback used to select a key for each element.
- elementSelector
- (element: T) => V
A callback that selects a value for each element.
Returns
toMap(source, keySelector)
Creates a Map for the elements of the Query.
Declaration
export declare function toMap<T, K>(source: Iterable<T>, keySelector: (element: T) => K): Map<K, T>;
Type Parameters
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select a key for each element. Scalar
Returns
toMap(source, keySelector, elementSelector)
Creates a Map for the elements of the Query.
Declaration
export declare function toMap<T, K, V>(source: Iterable<T>, keySelector: (element: T) => K, elementSelector: (element: T) => V): Map<K, V>;
Type Parameters
- T
- K
- V
Parameters
- keySelector
- (element: T) => K
A callback used to select a key for each element.
- elementSelector
- (element: T) => V
A callback that selects a value for each element. Scalar
Returns
toObject(source, prototype, keySelector)
Creates an Object for the elements of source
. Properties are added via Object.defineProperty
.
// As a regular object
const obj = toObject(`"`, 1], ["y", 2]], undefined, a => a[0]);
obj.x; // ["x", 1]
obj.y; // ["y", 2]
typeof obj.toString; // function
// with a custom prototype
const baseObject = { toString() { return `${this.x}:${this.y}` } };
const obj = toObject(`"`, 1], ["y", 2]], baseObject, a => a[0]);
obj.x; // ["x", 1]
obj.y; // ["y", 2]
typeof obj.toString; // function
obj.toString(); // "x",1:"y",2
// with a null prototype
const obj = toObject(`"`, 1], ["y", 2]], null, a => a[0]);
obj.x; // ["x", 1]
obj.y; // ["y", 2]
typeof obj.toString; // undefined
Declaration
export declare function toObject<T, TProto extends object, K extends PropertyKey>(source: Iterable<T>, prototype: TProto, keySelector: (element: T) => K): TProto & Record<K, T>;
Type Parameters
- T
- TProto
- K
Parameters
- prototype
- TProto
The prototype for the object. If prototype
is null
, an object with a null
prototype is created. If prototype
is undefined
, the default Object.prototype
is used.
- keySelector
- (element: T) => K
A callback used to select a key for each element. Scalar
Returns
toObject(source, prototype, keySelector)
Creates an Object for the elements of source
. Properties are added via Object.defineProperty
.
// As a regular object
const obj = toObject(`"`, 1], ["y", 2]], undefined, a => a[0]);
obj.x; // ["x", 1]
obj.y; // ["y", 2]
typeof obj.toString; // function
// with a custom prototype
const baseObject = { toString() { return `${this.x}:${this.y}` } };
const obj = toObject(`"`, 1], ["y", 2]], baseObject, a => a[0]);
obj.x; // ["x", 1]
obj.y; // ["y", 2]
typeof obj.toString; // function
obj.toString(); // "x",1:"y",2
// with a null prototype
const obj = toObject(`"`, 1], ["y", 2]], null, a => a[0]);
obj.x; // ["x", 1]
obj.y; // ["y", 2]
typeof obj.toString; // undefined
Declaration
export declare function toObject<T, TProto extends object>(source: Iterable<T>, prototype: TProto, keySelector: (element: T) => PropertyKey): TProto & Record<PropertyKey, T>;
Type Parameters
- T
- TProto
Parameters
- prototype
- TProto
The prototype for the object. If prototype
is null
, an object with a null
prototype is created. If prototype
is undefined
, the default Object.prototype
is used.
- keySelector
- (element: T) => PropertyKey
A callback used to select a key for each element. Scalar
Returns
toObject(source, prototype, keySelector)
Creates an Object for the elements of source
. Properties are added via Object.defineProperty
.
// As a regular object
const obj = toObject(`"`, 1], ["y", 2]], undefined, a => a[0]);
obj.x; // ["x", 1]
obj.y; // ["y", 2]
typeof obj.toString; // function
// with a custom prototype
const baseObject = { toString() { return `${this.x}:${this.y}` } };
const obj = toObject(`"`, 1], ["y", 2]], baseObject, a => a[0]);
obj.x; // ["x", 1]
obj.y; // ["y", 2]
typeof obj.toString; // function
obj.toString(); // "x",1:"y",2
// with a null prototype
const obj = toObject(`"`, 1], ["y", 2]], null, a => a[0]);
obj.x; // ["x", 1]
obj.y; // ["y", 2]
typeof obj.toString; // undefined
Declaration
export declare function toObject<T, K extends PropertyKey>(source: Iterable<T>, prototype: object | null | undefined, keySelector: (element: T) => K): Record<K, T>;
Type Parameters
- T
- K
Parameters
- prototype
- object | null | undefined
The prototype for the object. If prototype
is null
, an object with a null
prototype is created. If prototype
is undefined
, the default Object.prototype
is used.
- keySelector
- (element: T) => K
A callback used to select a key for each element. Scalar
Returns
toObject(source, prototype, keySelector)
Creates an Object for the elements of source
. Properties are added via Object.defineProperty
.
// As a regular object
const obj = toObject(`"`, 1], ["y", 2]], undefined, a => a[0]);
obj.x; // ["x", 1]
obj.y; // ["y", 2]
typeof obj.toString; // function
// with a custom prototype
const baseObject = { toString() { return `${this.x}:${this.y}` } };
const obj = toObject(`"`, 1], ["y", 2]], baseObject, a => a[0]);
obj.x; // ["x", 1]
obj.y; // ["y", 2]
typeof obj.toString; // function
obj.toString(); // "x",1:"y",2
// with a null prototype
const obj = toObject(`"`, 1], ["y", 2]], null, a => a[0]);
obj.x; // ["x", 1]
obj.y; // ["y", 2]
typeof obj.toString; // undefined
Declaration
export declare function toObject<T>(source: Iterable<T>, prototype: object | null | undefined, keySelector: (element: T) => PropertyKey): Record<PropertyKey, T>;
Type Parameters
- T
Parameters
- prototype
- object | null | undefined
The prototype for the object. If prototype
is null
, an object with a null
prototype is created. If prototype
is undefined
, the default Object.prototype
is used.
- keySelector
- (element: T) => PropertyKey
A callback used to select a key for each element. Scalar
Returns
toObject(source, prototype, keySelector, elementSelector, descriptorSelector)
Creates an Object for the elements of source
. Properties are added via Object.defineProperty
.
// As a regular object
const obj = toObject(`"`, 1], ["y", 2]], undefined, a => a[0], a => a[1]);
obj.x; // 1
obj.y; // 2
typeof obj.toString; // function
// with a custom prototype
const baseObject = { toString() { return `${this.x}:${this.y}` } };
const obj = toObject(`"`, 1], ["y", 2]], baseObject, a => a[0], a => a[1]);
obj.x; // 1
obj.y; // 2
typeof obj.toString; // function
obj.toString(); // 1:2
// with a null prototype
const obj = toObject(`"`, 1], ["y", 2]], null, a => a[0], a => a[1]);
obj.x; // 1
obj.y; // 2
typeof obj.toString; // undefined
Declaration
export declare function toObject<T, TProto extends object, K extends PropertyKey, V>(source: Iterable<T>, prototype: TProto, keySelector: (element: T) => K, elementSelector: (element: T) => V, descriptorSelector?: (key: K, value: V) => TypedPropertyDescriptor<V>): TProto & Record<K, V>;
Type Parameters
- T
- TProto
- K
- V
Parameters
- prototype
- TProto
The prototype for the object. If prototype
is null
, an object with a null
prototype is created. If prototype
is undefined
, the default Object.prototype
is used.
- keySelector
- (element: T) => K
A callback used to select a key for each element.
- elementSelector
- (element: T) => V
A callback that selects a value for each element.
- descriptorSelector
- (key: K, value: V) => TypedPropertyDescriptor<V>
A callback that defines the PropertyDescriptor
for each property.
Scalar
Returns
toObject(source, prototype, keySelector, elementSelector, descriptorSelector)
Creates an Object for the elements of source
. Properties are added via Object.defineProperty
.
// As a regular object
const obj = toObject(`"`, 1], ["y", 2]], undefined, a => a[0], a => a[1]);
obj.x; // 1
obj.y; // 2
typeof obj.toString; // function
// with a custom prototype
const baseObject = { toString() { return `${this.x}:${this.y}` } };
const obj = toObject(`"`, 1], ["y", 2]], baseObject, a => a[0], a => a[1]);
obj.x; // 1
obj.y; // 2
typeof obj.toString; // function
obj.toString(); // 1:2
// with a null prototype
const obj = toObject(`"`, 1], ["y", 2]], null, a => a[0], a => a[1]);
obj.x; // 1
obj.y; // 2
typeof obj.toString; // undefined
Declaration
export declare function toObject<T, TProto extends object, V>(source: Iterable<T>, prototype: TProto, keySelector: (element: T) => PropertyKey, elementSelector: (element: T) => V, descriptorSelector?: (key: PropertyKey, value: V) => TypedPropertyDescriptor<V>): TProto & Record<PropertyKey, V>;
Type Parameters
- T
- TProto
- V
Parameters
- prototype
- TProto
The prototype for the object. If prototype
is null
, an object with a null
prototype is created. If prototype
is undefined
, the default Object.prototype
is used.
- keySelector
- (element: T) => PropertyKey
A callback used to select a key for each element.
- elementSelector
- (element: T) => V
A callback that selects a value for each element.
- descriptorSelector
- (key: PropertyKey, value: V) => TypedPropertyDescriptor<V>
A callback that defines the PropertyDescriptor
for each property.
Scalar
Returns
toObject(source, prototype, keySelector, elementSelector, descriptorSelector)
Creates an Object for the elements of source
. Properties are added via Object.defineProperty
.
// As a regular object
const obj = toObject(`"`, 1], ["y", 2]], undefined, a => a[0], a => a[1]);
obj.x; // 1
obj.y; // 2
typeof obj.toString; // function
// with a custom prototype
const baseObject = { toString() { return `${this.x}:${this.y}` } };
const obj = toObject(`"`, 1], ["y", 2]], baseObject, a => a[0], a => a[1]);
obj.x; // 1
obj.y; // 2
typeof obj.toString; // function
obj.toString(); // 1:2
// with a null prototype
const obj = toObject(`"`, 1], ["y", 2]], null, a => a[0], a => a[1]);
obj.x; // 1
obj.y; // 2
typeof obj.toString; // undefined
Declaration
export declare function toObject<T, K extends PropertyKey, V>(source: Iterable<T>, prototype: object | null | undefined, keySelector: (element: T) => K, elementSelector: (element: T) => V, descriptorSelector?: (key: K, value: V) => TypedPropertyDescriptor<V>): Record<K, V>;
Type Parameters
- T
- K
- V
Parameters
- prototype
- object | null | undefined
The prototype for the object. If prototype
is null
, an object with a null
prototype is created. If prototype
is undefined
, the default Object.prototype
is used.
- keySelector
- (element: T) => K
A callback used to select a key for each element.
- elementSelector
- (element: T) => V
A callback that selects a value for each element.
- descriptorSelector
- (key: K, value: V) => TypedPropertyDescriptor<V>
A callback that defines the PropertyDescriptor
for each property.
Scalar
Returns
toObject(source, prototype, keySelector, elementSelector, descriptorSelector)
Creates an Object for the elements of source
. Properties are added via Object.defineProperty
.
// As a regular object
const obj = toObject(`"`, 1], ["y", 2]], undefined, a => a[0], a => a[1]);
obj.x; // 1
obj.y; // 2
typeof obj.toString; // function
// with a custom prototype
const baseObject = { toString() { return `${this.x}:${this.y}` } };
const obj = toObject(`"`, 1], ["y", 2]], baseObject, a => a[0], a => a[1]);
obj.x; // 1
obj.y; // 2
typeof obj.toString; // function
obj.toString(); // 1:2
// with a null prototype
const obj = toObject(`"`, 1], ["y", 2]], null, a => a[0], a => a[1]);
obj.x; // 1
obj.y; // 2
typeof obj.toString; // undefined
Declaration
export declare function toObject<T, V>(source: Iterable<T>, prototype: object | null | undefined, keySelector: (element: T) => PropertyKey, elementSelector: (element: T) => V, descriptorSelector?: (key: PropertyKey, value: V) => TypedPropertyDescriptor<V>): Record<PropertyKey, V>;
Type Parameters
- T
- V
Parameters
- prototype
- object | null | undefined
The prototype for the object. If prototype
is null
, an object with a null
prototype is created. If prototype
is undefined
, the default Object.prototype
is used.
- keySelector
- (element: T) => PropertyKey
A callback used to select a key for each element.
- elementSelector
- (element: T) => V
A callback that selects a value for each element.
- descriptorSelector
- (key: PropertyKey, value: V) => TypedPropertyDescriptor<V>
A callback that defines the PropertyDescriptor
for each property.
Scalar
Returns
toObject(source, prototype, keySelector, elementSelector, descriptorSelector)
Creates an Object for the elements of source
. Properties are added via Object.defineProperty
.
// As a regular object
const obj = toObject(`"`, 1], ["y", 2]], undefined, a => a[0], a => a[1]);
obj.x; // 1
obj.y; // 2
typeof obj.toString; // function
// with a custom prototype
const baseObject = { toString() { return `${this.x}:${this.y}` } };
const obj = toObject(`"`, 1], ["y", 2]], baseObject, a => a[0], a => a[1]);
obj.x; // 1
obj.y; // 2
typeof obj.toString; // function
obj.toString(); // 1:2
// with a null prototype
const obj = toObject(`"`, 1], ["y", 2]], null, a => a[0], a => a[1]);
obj.x; // 1
obj.y; // 2
typeof obj.toString; // undefined
Declaration
export declare function toObject<T, V>(source: Iterable<T>, prototype: object | null | undefined, keySelector: (element: T) => PropertyKey, elementSelector: (element: T) => V, descriptorSelector?: (key: PropertyKey, value: V) => PropertyDescriptor): object;
Type Parameters
- T
- V
Parameters
- prototype
- object | null | undefined
The prototype for the object. If prototype
is null
, an object with a null
prototype is created. If prototype
is undefined
, the default Object.prototype
is used.
- keySelector
- (element: T) => PropertyKey
A callback used to select a key for each element.
- elementSelector
- (element: T) => V
A callback that selects a value for each element.
- descriptorSelector
- (key: PropertyKey, value: V) => PropertyDescriptor
A callback that defines the PropertyDescriptor
for each property.
Scalar
Returns
topMost(source, predicate, equaler)
Filters a HierarchyIterable
to the top-most elements. Elements that are a descendant of any other
element in the iterable are removed.
Declaration
export declare function topMost<TNode, T extends TNode, U extends T>(source: HierarchyIterable<TNode, T>, predicate: (value: T) => value is U, equaler?: Equaler<TNode>): HierarchyIterable<TNode, U>;
Type Parameters
- TNode
- T
- U
Parameters
- predicate
- (value: T) => value is U
An optional callback used to filter the results.
Returns
topMost(source, predicate, equaler)
Creates a HierarchyIterable
for the top-most elements. Elements that are a descendant of any other
element are removed.
Declaration
export declare function topMost<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>, predicate?: (value: T) => boolean, equaler?: Equaler<TNode>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- predicate
- (value: T) => boolean
An optional callback used to filter the results.
Returns
toSet(source)
Creates a Set for the elements of the Iterable.
Declaration
export declare function toSet<T>(source: Iterable<T>): Set<T>;
Type Parameters
- T
Parameters
Returns
toSet(source, elementSelector)
Creates a Set for the elements of the Iterable.
Declaration
export declare function toSet<T, V>(source: Iterable<T>, elementSelector: (element: T) => V): Set<V>;
Type Parameters
- T
- V
Parameters
- elementSelector
- (element: T) => V
A callback that selects a value for each element. Scalar
Returns
union(left, right, equaler)
Creates a subquery for the set union of two Iterable
objects.
Declaration
export declare function union<TNode, T extends TNode>(left: HierarchyIterable<TNode, T>, right: Iterable<T>, equaler?: Equaler<T>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
Returns
union(left, right, equaler)
Creates a subquery for the set union of two Iterable
objects.
Declaration
export declare function union<TNode, T extends TNode>(left: Iterable<T>, right: HierarchyIterable<TNode, T>, equaler?: Equaler<T>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
Parameters
Returns
union(left, right, equaler)
Creates a subquery for the set union of two Iterable
objects.
Declaration
export declare function union<T>(left: Iterable<T>, right: Iterable<T>, equaler?: Equaler<T>): Iterable<T>;
Type Parameters
- T
Parameters
Returns
unionBy(left, right, keySelector, keyEqualer)
Creates a subquery for the set union of two Iterable
objects, where set identity is determined by the selected key.
Declaration
export declare function unionBy<TNode, T extends TNode, K>(left: HierarchyIterable<TNode, T>, right: Iterable<T>, keySelector: (element: T) => K, keyEqualer?: Equaler<K>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for each element.
Returns
unionBy(left, right, keySelector, keyEqualer)
Creates a subquery for the set union of two Iterable
objects, where set identity is determined by the selected key.
Declaration
export declare function unionBy<TNode, T extends TNode, K>(left: Iterable<T>, right: HierarchyIterable<TNode, T>, keySelector: (element: T) => K, keyEqualer?: Equaler<K>): HierarchyIterable<TNode, T>;
Type Parameters
- TNode
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for each element.
Returns
unionBy(left, right, keySelector, keyEqualer)
Creates a subquery for the set union of two Iterable
objects, where set identity is determined by the selected key.
Declaration
export declare function unionBy<T, K>(left: Iterable<T>, right: Iterable<T>, keySelector: (element: T) => K, keyEqualer?: Equaler<K>): Iterable<T>;
Type Parameters
- T
- K
Parameters
- keySelector
- (element: T) => K
A callback used to select the key for each element.
Returns
unzip(source)
Unzips a sequence of tuples into a tuple of sequences.
Declaration
export declare function unzip<T extends readonly any[] | []>(source: Iterable<T>): {
[I in keyof T]: T[I][];
};
Type Parameters
- T
Parameters
Returns
unzip(source, partSelector)
Unzips a sequence of tuples into a tuple of sequences.
Declaration
export declare function unzip<T, U extends readonly any[] | []>(source: Iterable<T>, partSelector: (value: T) => U): {
[I in keyof U]: U[I][];
};
Type Parameters
- T
- U
Parameters
- partSelector
- (value: T) => U
A callback that converts a result into a tuple. Scalar
Returns
zip(left, right)
Creates a subquery that combines two Iterable
objects by combining elements
in tuples.
Declaration
export declare function zip<T, U>(left: Iterable<T>, right: Iterable<U>): Iterable<[T, U]>;
Type Parameters
- T
- U
Parameters
Returns
zip(left, right, selector)
Creates a subquery that combines two Iterable
objects by combining elements
using the supplied callback.
Declaration
export declare function zip<T, U, R>(left: Iterable<T>, right: Iterable<U>, selector: (left: T, right: U) => R): Iterable<R>;
Type Parameters
- T
- U
- R
Parameters
- selector
- (left: T, right: U) => R
A callback used to combine two elements. Join
Returns