@esfx/iter-query Package
An iteration and query API for ECMAScript iterables.
Installation
npm i @esfx/iter-query
Usage
import { Query } from "@esfx/iter-query";
let q = Query
.from(books)
.filter(book => book.author === "Alice")
.groupBy(book => book.releaseYear);
Classes
HierarchyQuery
Represents a sequence of hierarchically organized values.
OrderedHierarchyQuery
Represents an ordered sequence of hierarchically organized values.
OrderedQuery
Represents an ordered sequence of elements.
Query
A Query
represents a series of operations that act upon an Iterable
or ArrayLike. Evaluation of
these operations is deferred until the either a scalar value is requested from the Query
or the
Query
is iterated.
Functions
from(source)
Creates a Query
from a Iterable
source.
Declaration
export declare function from<TNode, T extends TNode>(source: OrderedHierarchyIterable<TNode, T>): OrderedHierarchyQuery<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- source
- OrderedHierarchyIterable<TNode, T>
Returns
from(source)
Declaration
export declare function from<TNode, T extends TNode>(source: HierarchyIterable<TNode, T>): HierarchyQuery<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- source
- HierarchyIterable<TNode, T>
Returns
from(source, provider)
Declaration
export declare function from<TNode, T extends TNode>(source: OrderedIterable<T>, provider: HierarchyProvider<TNode>): OrderedHierarchyQuery<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- source
- OrderedIterable<T>
- provider
- HierarchyProvider<TNode>
Returns
from(source, provider)
Declaration
export declare function from<TNode, T extends TNode>(source: Iterable<T>, provider: HierarchyProvider<TNode>): HierarchyQuery<TNode, T>;
Type Parameters
- TNode
- T
Parameters
- source
- Iterable<T>
- provider
- HierarchyProvider<TNode>
Returns
from(source)
Declaration
export declare function from<T>(source: OrderedIterable<T>): OrderedQuery<T>;
Type Parameters
- T
Parameters
- source
- OrderedIterable<T>
Returns
from(source)
Declaration
export declare function from<T extends readonly unknown[] | []>(source: Iterable<T>): Query<T>;
Type Parameters
- T
Parameters
- source
- Iterable<T>
Returns
from(source)
Declaration
export declare function from<T>(source: Iterable<T>): Query<T>;
Type Parameters
- T
Parameters
- source
- Iterable<T>
Returns
Type Aliases
GroupedQueryFlow
Declaration
export declare type GroupedQueryFlow<S, K, T> = S extends Hierarchical<infer TNode> ? Query<HierarchyGrouping<K, TNode, TNode & T>> : Query<Grouping<K, T>>;
Type Parameters
- S
- K
- T
HierarchyQueryFlow
Declaration
export declare type HierarchyQueryFlow<S, TNode extends (T extends TNode ? unknown : never), T> = S extends OrderedIterable<any> ? OrderedHierarchyQuery<TNode, TNode & T> : HierarchyQuery<TNode, TNode & T>;
Type Parameters
- S
- TNode
- T
MergeQueryFlow
Declaration
export declare type MergeQueryFlow<L, R, T> = L extends Hierarchical<infer LTNode> ? R extends Hierarchical<infer RTNode> ? HierarchyQuery<LTNode | RTNode, LTNode & T | RTNode & T> : HierarchyQuery<LTNode, LTNode & T> : R extends Hierarchical<infer RTNode> ? HierarchyQuery<RTNode, RTNode & T> : Query<T>;
Type Parameters
- L
- R
- T
OrderedQueryFlow
Declaration
export declare type OrderedQueryFlow<S, T> = S extends Hierarchical<infer TNode> ? OrderedHierarchyQuery<TNode, TNode & T> : OrderedQuery<T>;
Type Parameters
- S
- T
PagedQueryFlow
Declaration
export declare type PagedQueryFlow<S, T> = S extends Hierarchical<infer TNode> ? Query<HierarchyPage<TNode, TNode & T>> : Query<Page<T>>;
Type Parameters
- S
- T
QueryFlow
Declaration
export declare type QueryFlow<S, T> = S extends OrderedIterable<any> ? OrderedQueryFlow<S, T> : UnorderedQueryFlow<S, T>;
Type Parameters
- S
- T
UnorderedQueryFlow
Declaration
export declare type UnorderedQueryFlow<S, T> = S extends Hierarchical<infer TNode> ? HierarchyQuery<TNode, TNode & T> : Query<T>;
Type Parameters
- S
- T