/*! Copyright 2018 Ron Buckton (rbuckton@chronicles.org) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /** @module "iterable-query" */ import { Queryable, HierarchyProvider, Hierarchical, Grouping, PossiblyAsyncOrderedHierarchyIterable, PossiblyAsyncHierarchyIterable, PossiblyAsyncOrderedIterable, AsyncQueryable, AsyncOrderedHierarchyIterable, AsyncOrderedIterable, Page, KeyValuePair, AsyncHierarchyIterable, AsyncChoice, QueriedType, WritableArrayLike } from "./types"; import { Lookup } from "./lookup"; import { ConsumeAsyncOptions } from "./fn"; import { Query } from "./query"; import { Comparison, Comparer, EqualityComparison, Equaler } from '@esfx/equatable'; import { HashSet } from '@esfx/collections-hashset'; import { HashMap } from '@esfx/collections-hashmap'; /** * Flows the base type of a [[Query]] as an unordered query with a new iterated type. */ export declare type AsyncUnorderedQueryFlow, T> = S extends Hierarchical ? AsyncHierarchyQuery : AsyncQuery; /** * Flows the base type of a [[Query]] as an ordered query with a new iterated type. */ export declare type AsyncOrderedQueryFlow, T> = S extends Hierarchical ? AsyncOrderedHierarchyQuery : AsyncOrderedQuery; /** * Flows the base type of a [[Query]] as a hierarchical query with a new iterated type. */ export declare type AsyncHierarchyQueryFlow, T> = S extends AsyncOrderedIterable ? AsyncOrderedHierarchyQuery : AsyncHierarchyQuery; /** * Flows the base type of a [[Query]] with a new iterated type. */ export declare type AsyncQueryFlow, T> = S extends AsyncOrderedIterable ? AsyncOrderedQueryFlow : AsyncUnorderedQueryFlow; /** * Creates an [[AsyncQuery]] from an [[AsyncQueryable]] source. * * @param source An [[AsyncQueryable]] object. */ export declare function fromAsync(source: PossiblyAsyncOrderedHierarchyIterable): AsyncOrderedHierarchyQuery; /** * Creates an [[AsyncQuery]] from an [[AsyncQueryable]] source. * * @param source An [[AsyncQueryable]] object. */ export declare function fromAsync(source: PossiblyAsyncHierarchyIterable): AsyncHierarchyQuery; /** * Creates an [[AsyncQuery]] from an [[AsyncQueryable]] source. * * @param source An [[AsyncQueryable]] object. */ export declare function fromAsync(source: PossiblyAsyncOrderedIterable): AsyncOrderedQuery; /** * Creates an [[AsyncQuery]] from an [[AsyncQueryable]] source. * * @param source An [[AsyncQueryable]] object. */ export declare function fromAsync(source: AsyncQueryable): AsyncQuery; /** * Creates an `AsyncHierarchyQuery` from an [[AsyncQueryable]] source. * * @param source An [[AsyncQueryable]] object. * @param hierarchy A `HierarchyProvider` object. */ export declare function fromAsync(source: PossiblyAsyncOrderedIterable, hierarchy: HierarchyProvider): AsyncOrderedHierarchyQuery; /** * Creates an `AsyncHierarchyQuery` from an [[AsyncQueryable]] source. * * @param source An [[AsyncQueryable]] object. * @param hierarchy A `HierarchyProvider` object. */ export declare function fromAsync(source: AsyncQueryable, hierarchy: HierarchyProvider): AsyncHierarchyQuery; /** * An [[AsyncQuery]] represents a series of operations that act upon an [[AsyncIterable]], [[Iterable]] * or `ArrayLike`. Evaluation of these operations is deferred until the either a scalar value is * requested from the [[AsyncQuery]] or the [[AsyncQuery]] is iterated. */ export declare class AsyncQuery implements AsyncIterable { private _source; /** * Creates an [[AsyncQuery]] from an [[AsyncQueryable]] source. * * @param source An [[AsyncQueryable]] object. */ constructor(source: AsyncQueryable); [Symbol.asyncIterator](): AsyncIterator; /** * Creates an [[AsyncQuery]] from an [[AsyncQueryable]] source. * * @param source An [[AsyncQueryable]] object. * @category Query */ static from(source: PossiblyAsyncOrderedHierarchyIterable): AsyncOrderedHierarchyQuery; /** * Creates an [[AsyncQuery]] from an [[AsyncQueryable]] source. * * @param source An [[AsyncQueryable]] object. * @category Query */ static from(source: PossiblyAsyncHierarchyIterable): AsyncHierarchyQuery; /** * Creates an [[AsyncQuery]] from an [[AsyncQueryable]] source. * * @param source An [[AsyncQueryable]] object. * @category Query */ static from(source: PossiblyAsyncOrderedIterable): AsyncOrderedQuery; /** * Creates an [[AsyncQuery]] from an [[AsyncQueryable]] source. * * @param source An [[AsyncQueryable]] object. * @category Query */ static from(source: AsyncQueryable): AsyncQuery; /** * Creates an `AsyncHierarchyQuery` from an [[AsyncQueryable]] source. * * @param source An [[AsyncQueryable]] object. * @param hierarchy A `HierarchyProvider` object. * @category Query */ static from(source: PossiblyAsyncOrderedIterable, hierarchy: HierarchyProvider): AsyncOrderedHierarchyQuery; /** * Creates an `AsyncHierarchyQuery` from an [[AsyncQueryable]] source. * * @param source An [[AsyncQueryable]] object. * @param hierarchy A `HierarchyProvider` object. * @category Query */ static from(source: AsyncQueryable, hierarchy: HierarchyProvider): AsyncHierarchyQuery; /** * Creates an [[AsyncQuery]] for the provided elements. * * @param elements The elements of the `Query`. * @category Query */ static of(...elements: (PromiseLike | T)[]): AsyncQuery; /** * Creates an [[AsyncQuery]] with no elements. * @category Query */ static empty(): AsyncQuery; /** * Creates an [[AsyncQuery]] over a single element. * * @param value The only element for the `Query`. * @category Query */ static once(value: PromiseLike | T): AsyncQuery; /** * Creates an [[AsyncQuery]] for a value repeated a provided number of times. * * @param value The value for each element of the `Query`. * @param count The number of times to repeat the value. * @category Query */ static repeat(value: PromiseLike | T, count: number): AsyncQuery; /** * Creates an [[AsyncQuery]] that repeats the provided value forever. * * @param value The value for each element of the `Query`. * @category Query */ static continuous(value: PromiseLike | T): AsyncQuery; /** * Creates an [[AsyncQuery]] whose values are provided by a callback executed a provided number of * times. * * @param count The number of times to execute the callback. * @param generator The callback to execute. * @category Query */ static generate(count: number, generator: (offset: number) => PromiseLike | T): AsyncQuery; /** * Creates an `AsyncHierarchyQuery` from a root node and a `HierarchyProvider`. * * @param root The root node of the hierarchy. * @param hierarchy A `HierarchyProvider` object. * @category Query */ static hierarchy(root: PromiseLike | T, hierarchy: HierarchyProvider): AsyncHierarchyQuery; /** * Creates an [[AsyncQuery]] that, when iterated, consumes the provided `AsyncIterator`. * * @param iterator An `AsyncIterator` object. * @category Query */ static consume(iterator: AsyncIterator, options?: ConsumeAsyncOptions): AsyncQuery; /** * Creates an [[AsyncQuery]] that iterates the elements from one of two sources based on the result of a * lazily evaluated condition. * * @param condition A callback used to choose a source. * @param thenQueryable The source to use when the callback evaluates to `true`. * @param elseQueryable The source to use when the callback evaluates to `false`. * @category Query */ static if(condition: () => PromiseLike | boolean, thenQueryable: AsyncQueryable, elseQueryable?: AsyncQueryable): AsyncQuery; /** * Creates an [[AsyncQuery]] that iterates the elements from sources picked from a list based on the * result of a lazily evaluated choice. * * @param chooser A callback used to choose a source. * @param choices A list of sources * @param otherwise A default source to use when another choice could not be made. * @category Query */ static choose(chooser: () => PromiseLike | K, choices: AsyncQueryable>, otherwise?: AsyncQueryable): AsyncQuery; /** * Creates an [[AsyncQuery]] for the own property keys of an object. * * @param source An object. * @category Query */ static objectKeys(source: PromiseLike | T): AsyncQuery>; /** * Creates an [[AsyncQuery]] for the own property values of an object. * * @param source An object. * @category Query */ static objectValues(source: PromiseLike | T): AsyncQuery]>; /** * Creates an [[AsyncQuery]] for the own property key-value pairs of an object. * * @param source An object. * @category Query */ static objectEntries(source: PromiseLike | T): AsyncQuery>>; /** * Creates a subquery whose elements match the supplied predicate. * * @param predicate A callback used to match each element. * @category Subquery */ filter(predicate: (element: T, offset: number) => element is U): AsyncUnorderedQueryFlow; /** * Creates a subquery whose elements match the supplied predicate. * * @param predicate A callback used to match each element. * @category Subquery */ filter(predicate: (element: T, offset: number) => boolean | PromiseLike): AsyncUnorderedQueryFlow; /** * Creates a subquery where the selected key for each element matches the supplied predicate. * * @param keySelector A callback used to select the key for each element. * @param predicate A callback used to match each key. * @category Subquery */ filterBy(keySelector: (element: T) => K, predicate: (key: K, offset: number) => boolean | PromiseLike): AsyncUnorderedQueryFlow; /** * Creates a subquery whose elements match the supplied predicate. * This is an alias for `filter`. * * @param predicate A callback used to match each element. * @category Subquery */ where(predicate: (element: T, offset: number) => element is U): AsyncUnorderedQueryFlow; /** * Creates a subquery whose elements match the supplied predicate. * This is an alias for `filter`. * * @param predicate A callback used to match each element. * @category Subquery */ where(predicate: (element: T, offset: number) => boolean | PromiseLike): AsyncUnorderedQueryFlow; /** * Creates a subquery where the selected key for each element matches the supplied predicate. * * @param keySelector A callback used to select the key for each element. * @param predicate A callback used to match each key. * @category Subquery */ whereBy(keySelector: (element: T) => K, predicate: (key: K, offset: number) => boolean): AsyncUnorderedQueryFlow; /** * Creates a subquery whose elements are neither `null` nor `undefined`. * * @category Subquery */ filterDefined(): AsyncUnorderedQueryFlow>; /** * Creates a subquery where the selected key for each element is neither `null` nor `undefined`. * * @param keySelector A callback used to select the key for each element. * @category Subquery */ filterDefined(keySelector: (element: T) => K): AsyncUnorderedQueryFlow; /** * Creates a subquery whose elements are neither `null` nor `undefined`. * * NOTE: This is an alias for `filterDefined`. * * @category Subquery */ whereDefined(): AsyncUnorderedQueryFlow>; /** * Creates a subquery where the selected key for each element is neither `null` nor `undefined`. * * @param keySelector A callback used to select the key for each element. * @category Subquery */ whereDefined(keySelector: (element: T) => K): AsyncUnorderedQueryFlow; /** * Creates a subquery by applying a callback to each element. * * @param selector A callback used to map each element. * @category Subquery */ map(selector: (element: T, offset: number) => U | PromiseLike): AsyncQuery; /** * Creates a subquery by applying a callback to each element. * This is an alias for `map`. * * @param selector A callback used to map each element. * @category Subquery */ select(selector: (element: T, offset: number) => U | PromiseLike): AsyncQuery; /** * Creates a subquery that iterates the results of applying a callback to each element. * * @param projection A callback used to map each element into an iterable. * @category Subquery */ flatMap(projection: (element: T) => AsyncQueryable): AsyncQuery; /** * Creates a subquery that iterates the results of applying a callback to each element. * * @param projection A callback used to map each element into an iterable. * @category Subquery */ flatMap(projection: (element: T) => AsyncQueryable, resultSelector: (element: T, innerElement: U) => R | PromiseLike): AsyncQuery; /** * Creates a subquery that iterates the results of applying a callback to each element. * This is an alias for `flatMap`. * * @param projection A callback used to map each element into an iterable. * @category Subquery */ selectMany(projection: (element: T) => AsyncQueryable): AsyncQuery; /** * Creates a subquery that iterates the results of applying a callback to each element. * This is an alias for `flatMap`. * * @param projection A callback used to map each element into an iterable. * @category Subquery */ selectMany(projection: (element: T) => AsyncQueryable, resultSelector: (element: T, innerElement: U) => R | PromiseLike): AsyncQuery; /** * Creates a subquery that iterates the results of recursively expanding the * elements of the source. * * @param projection A callback used to recusively expand each element. * @category Subquery */ expand(projection: (element: T) => AsyncQueryable): AsyncQuery; /** * Lazily invokes a callback as each element of the query is iterated. * * @param callback The callback to invoke. * @category Subquery */ do(callback: (element: T, offset: number) => void): AsyncUnorderedQueryFlow; /** * Lazily invokes a callback as each element of the query is iterated. * * @param callback The callback to invoke. * @category Subquery */ do(callback: (element: T, offset: number) => PromiseLike): AsyncUnorderedQueryFlow; /** * Lazily invokes a callback as each element of the query is iterated. * * @param callback The callback to invoke. * @category Subquery */ do(callback: (element: T, offset: number) => PromiseLike | void): AsyncUnorderedQueryFlow; /** * Lazily invokes a callback as each element of the query is iterated. * This is an alias for `do`. * * @param callback The callback to invoke. * @category Subquery */ tap(callback: (element: T, offset: number) => void): AsyncUnorderedQueryFlow; /** * Lazily invokes a callback as each element of the query is iterated. * This is an alias for `do`. * * @param callback The callback to invoke. * @category Subquery */ tap(callback: (element: T, offset: number) => PromiseLike): AsyncUnorderedQueryFlow; /** * Lazily invokes a callback as each element of the query is iterated. * This is an alias for `do`. * * @param callback The callback to invoke. * @category Subquery */ tap(callback: (element: T, offset: number) => PromiseLike | void): AsyncUnorderedQueryFlow; /** * Pass the entire query to the provided callback, creating a new query from the result. * * @param callback A callback function. * @category Subquery */ through = Queryable>(callback: (source: this) => R): AsyncQueryFlow>; /** * Creates a subquery whose elements are in the reverse order. * @category Subquery */ reverse(): AsyncUnorderedQueryFlow; /** * Creates a subquery with every instance of the specified value removed. * * @param values The values to exclude. * @category Subquery */ exclude(...values: [T | PromiseLike, ...(T | PromiseLike)[]]): AsyncUnorderedQueryFlow; /** * Creates a subquery containing all elements except the first elements up to the supplied * count. * * @param count The number of elements to skip. * @category Subquery */ skip(count: number): AsyncUnorderedQueryFlow; /** * Creates a subquery containing all elements except the last elements up to the supplied * count. * * @param count The number of elements to skip. * @category Subquery */ skipRight(count: number): AsyncUnorderedQueryFlow; /** * Creates a subquery containing all elements except the first elements that match * the supplied predicate. * * @param predicate A callback used to match each element. * @category Subquery */ skipWhile(predicate: (element: T) => boolean | PromiseLike): AsyncUnorderedQueryFlow; /** * Creates a subquery containing all elements except the first elements that do not match * the supplied predicate. * * @param predicate A callback used to match each element. * @category Subquery */ skipUntil(predicate: (element: T) => boolean): AsyncUnorderedQueryFlow; /** * Creates a subquery containing the first elements up to the supplied * count. * * @param count The number of elements to take. * @category Subquery */ take(count: number): AsyncUnorderedQueryFlow; /** * Creates a subquery containing the last elements up to the supplied * count. * * @param count The number of elements to take. * @category Subquery */ takeRight(count: number): AsyncUnorderedQueryFlow; /** * Creates a subquery containing the first elements that match the supplied predicate. * * @param predicate A callback used to match each element. * @category Subquery */ takeWhile(predicate: (element: T) => element is U): AsyncUnorderedQueryFlow; /** * Creates a subquery containing the first elements that match the supplied predicate. * * @param predicate A callback used to match each element. * @category Subquery */ takeWhile(predicate: (element: T) => boolean | PromiseLike): AsyncUnorderedQueryFlow; /** * Creates a subquery containing the first elements that do not match the supplied predicate. * * @param predicate A callback used to match each element. * @category Subquery */ takeUntil(predicate: (element: T) => boolean | PromiseLike): AsyncUnorderedQueryFlow; /** * Creates a subquery for the set intersection of this [[AsyncQuery]] and another [[AsyncQueryable]]. * * @param right An [[AsyncQueryable]] object. * @param equaler An [[Equaler]] object used to compare equality. * @category Subquery */ intersect(right: PossiblyAsyncHierarchyIterable, equaler?: Equaler): AsyncHierarchyQuery; /** * Creates a subquery for the set intersection of this [[AsyncQuery]] and another [[AsyncQueryable]]. * * @param right An [[AsyncQueryable]] object. * @param equaler An [[Equaler]] object used to compare equality. * @category Subquery */ intersect(right: AsyncQueryable, equaler?: Equaler): AsyncQuery; /** * Creates a subquery for the set intersection of this [[AsyncQuery]] and another [[AsyncQueryable]]. * * @param right An [[AsyncQueryable]] object. * @param equaler An [[Equaler]] object used to compare equality. * @category Subquery */ intersect(right: AsyncQueryable, equaler?: Equaler): AsyncQuery; /** * Creates a subquery for the set intersection of this [[AsyncQuery]] and another [[AsyncQueryable]], where set identity is determined by the selected key. * * @param right An [[AsyncQueryable]] object. * @param keySelector A callback used to select the key for each element. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Subquery */ intersectBy(right: PossiblyAsyncHierarchyIterable, keySelector: (element: T) => K, keyEqualer?: Equaler): AsyncHierarchyQuery; /** * Creates a subquery for the set intersection of this [[AsyncQuery]] and another [[AsyncQueryable]], where set identity is determined by the selected key. * * @param right An [[AsyncQueryable]] object. * @param keySelector A callback used to select the key for each element. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Subquery */ intersectBy(right: AsyncQueryable, keySelector: (element: T) => K, keyEqualer?: Equaler): AsyncQuery; /** * Creates a subquery for the set intersection of this [[AsyncQuery]] and another [[AsyncQueryable]], where set identity is determined by the selected key. * * @param right An [[AsyncQueryable]] object. * @param keySelector A callback used to select the key for each element. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Subquery */ intersectBy(right: AsyncQueryable, keySelector: (element: T) => K, keyEqualer?: Equaler): AsyncQuery; /** * Creates a subquery for the set union of this [[AsyncQuery]] and another [[AsyncQueryable]]. * * @param right An [[AsyncQueryable]] object. * @param equaler An [[Equaler]] object used to compare equality. * @category Subquery */ union(right: AsyncQueryable, equaler?: Equaler): AsyncUnorderedQueryFlow; /** * Creates a subquery for the set union of this [[AsyncQuery]] and another [[AsyncQueryable]], where set identity is determined by the selected key. * * @param right An [[AsyncQueryable]] object. * @param keySelector A callback used to select the key for each element. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Subquery */ unionBy(right: AsyncQueryable, keySelector: (element: T) => K, keyEqualer?: Equaler): AsyncUnorderedQueryFlow; /** * Creates a subquery for the set difference (a.k.a. 'relative complement') between this [[AsyncQuery]] and another [[AsyncQueryable]]. * * @param right An [[AsyncQueryable]] object. * @param equaler An [[Equaler]] object used to compare equality. * @category Subquery */ except(right: AsyncQueryable, equaler?: Equaler): AsyncUnorderedQueryFlow; /** * Creates a subquery for the set difference between this and another [[AsyncQueryable]], where set identity is determined by the selected key. * * @param right An [[AsyncQueryable]] object. * @param keySelector A callback used to select the key for each element. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Subquery */ exceptBy(right: AsyncQueryable, keySelector: (element: T) => K, keyEqualer?: Equaler): AsyncUnorderedQueryFlow; /** * Creates a subquery for the set difference between this [[AsyncQuery]] and another [[AsyncQueryable]]. * * This is an alias for `except`. * * @param right An [[AsyncQueryable]] object. * @param equaler An [[Equaler]] object used to compare equality. * @category Subquery */ relativeComplement(right: AsyncQueryable, equaler?: Equaler): AsyncUnorderedQueryFlow; /** * Creates a subquery for the set difference between this [[AsyncQuery]] and another [[AsyncQueryable]]. * * This is an alias for `except`. * * @param right An [[AsyncQueryable]] object. * @param keySelector A callback used to select the key for each element. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Subquery */ relativeComplementBy(right: AsyncQueryable, keySelector: (element: T) => K, keyEqualer?: Equaler): AsyncUnorderedQueryFlow; /** * Creates a subquery for the symmetric difference between this [[AsyncQuery]] and another [[AsyncQueryable]]. * * @param right An [[AsyncQueryable]] object. * @param equaler An [[Equaler]] object used to compare equality. * @category Subquery */ symmetricDifference(right: AsyncQueryable, equaler?: Equaler): AsyncUnorderedQueryFlow; /** * Creates a subquery for the symmetric difference between this [[AsyncQuery]] and another [[AsyncQueryable]]. * * @param right An [[AsyncQueryable]] object. * @param keySelector A callback used to select the key for each element. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Subquery */ symmetricDifferenceBy(right: AsyncQueryable, keySelector: (element: T) => K, keyEqualer?: Equaler): AsyncUnorderedQueryFlow; /** * Creates a subquery for the symmetric difference between this [[AsyncQuery]] and another [[AsyncQueryable]]. * * This is an alias for `symmetricDifference`. * * @param right An [[AsyncQueryable]] object. * @param equaler An [[Equaler]] object used to compare equality. * @category Subquery */ xor(right: AsyncQueryable, equaler?: Equaler): AsyncUnorderedQueryFlow; /** * Creates a subquery for the symmetric difference between this [[AsyncQuery]] and another [[AsyncQueryable]]. * * This is an alias for `symmetricDifference`. * * @param right An [[AsyncQueryable]] object. * @param keySelector A callback used to select the key for each element. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Subquery */ xorBy(right: AsyncQueryable, keySelector: (element: T) => K, keyEqualer?: Equaler): AsyncUnorderedQueryFlow; /** * Creates a subquery that concatenates this [[AsyncQuery]] with another [[AsyncQueryable]]. * * @param right An [[AsyncQueryable]] object. * @category Subquery */ concat(right: AsyncQueryable): AsyncUnorderedQueryFlow; /** * Creates a subquery for the distinct elements of this [[AsyncQuery]]. * * @param equaler An [[Equaler]] object used to compare key equality. * @category Subquery */ distinct(equaler?: Equaler): AsyncUnorderedQueryFlow; /** * Creates a subquery for the distinct elements of this [[AsyncQuery]]. * * @param keySelector A callback used to select the key to determine uniqueness. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Subquery */ distinctBy(keySelector: (value: T) => K, keyEqualer?: Equaler): AsyncUnorderedQueryFlow; /** * Creates a subquery for the elements of this [[AsyncQuery]] with the provided value appended to the end. * * @param value The value to append. * @category Subquery */ append(value: PromiseLike | T): AsyncUnorderedQueryFlow; /** * Creates a subquery for the elements of this [[AsyncQuery]] with the provided value prepended to the beginning. * * @param value The value to prepend. * @category Subquery */ prepend(value: PromiseLike | T): AsyncUnorderedQueryFlow; /** * Creates a subquery for the elements of this [[AsyncQuery]] with the provided range * patched into the results. * * @param start The offset at which to patch the range. * @param skipCount The number of elements to skip from start. * @param range The range to patch into the result. * @category Subquery */ patch(start: number, skipCount?: number, range?: AsyncQueryable): AsyncUnorderedQueryFlow; /** * Creates a subquery that contains the provided default value if this [[AsyncQuery]] * contains no elements. * * @param defaultValue The default value. * @category Subquery */ defaultIfEmpty(defaultValue: PromiseLike | T): AsyncUnorderedQueryFlow; /** * Creates a subquery that splits this [[AsyncQuery]] into one or more pages. * While advancing from page to page is evaluated lazily, the elements of the page are * evaluated eagerly. * * @param pageSize The number of elements per page. * @category Subquery */ pageBy(pageSize: number): AsyncQuery>; /** * Creates a subquery whose elements are the contiguous ranges of elements that share the same key. * * @param keySelector A callback used to select the key for an element. * @category Subquery */ spanMap(keySelector: (element: T) => K): AsyncQuery>; /** * Creates a subquery whose values are computed from each element of the contiguous ranges of elements that share the same key. * * @param keySelector A callback used to select the key for an element. * @param elementSelector A callback used to select a value for an element. * @category Subquery */ spanMap(keySelector: (element: T) => K, elementSelector: (element: T) => V | PromiseLike): AsyncQuery>; /** * Creates a subquery whose values are computed from the contiguous ranges of elements that share the same key. * * @param keySelector A callback used to select the key for an element. * @param elementSelector A callback used to select a value for an element. * @param spanSelector A callback used to select a result from a contiguous range. * @category Subquery */ spanMap(keySelector: (element: T) => K, elementSelector: (element: T) => V | PromiseLike, spanSelector: (key: K, elements: Query) => PromiseLike | R): AsyncQuery; /** * Groups each element of this [[AsyncQuery]] by its key. * * @param keySelector A callback used to select the key for an element. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Subquery */ groupBy(keySelector: (element: T) => K, keyEqualer?: Equaler): AsyncQuery>; /** * Groups each element by its key. * * @param keySelector A callback used to select the key for an element. * @param elementSelector A callback used to select a value for an element. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Subquery */ groupBy(keySelector: (element: T) => K, elementSelector: (element: T) => V | PromiseLike, keyEqualer?: Equaler): AsyncQuery>; /** * Groups each element by its key. * * @param keySelector A callback used to select the key for an element. * @param elementSelector A callback used to select a value for an element. * @param resultSelector A callback used to select a result from a group. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Subquery */ groupBy(keySelector: (element: T) => K, elementSelector: (element: T) => V | PromiseLike, resultSelector: (key: K, elements: Query) => R, keyEqualer?: Equaler): AsyncQuery; /** * Creates a subquery containing the cumulative results of applying the provided callback to each element. * * @param accumulator The callback used to compute each result. * @category Subquery */ scan(accumulator: (current: T, element: T, offset: number) => T | PromiseLike): AsyncQuery; /** * Creates a subquery containing the cumulative results of applying the provided callback to each element. * * @param accumulator The callback used to compute each result. * @param seed An optional seed value. * @category Subquery */ scan(accumulator: (current: U, element: T, offset: number) => U | PromiseLike, seed: U): AsyncQuery; /** * Creates a subquery containing the cumulative results of applying the provided callback to each element in reverse. * * @param accumulator The callback used to compute each result. * @category Subquery */ scanRight(accumulator: (current: T, element: T, offset: number) => T | PromiseLike): AsyncQuery; /** * Creates a subquery containing the cumulative results of applying the provided callback to each element in reverse. * * @param accumulator The callback used to compute each result. * @param seed An optional seed value. * @category Subquery */ scanRight(accumulator: (current: U, element: T, offset: number) => U | PromiseLike, seed?: U): AsyncQuery; /** * Creates a grouped subquery for the correlated elements of this [[AsyncQuery]] and another [[AsyncQueryable]] object. * * @param inner A [[Queryable]] object. * @param outerKeySelector A callback used to select the key for an element in this [[AsyncQuery]]. * @param innerKeySelector A callback used to select the key for an element in the other [[Queryable]] object. * @param resultSelector A callback used to select the result for the correlated elements. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Join */ groupJoin(inner: AsyncQueryable, outerKeySelector: (element: T) => K, innerKeySelector: (element: I) => K, resultSelector: (outer: T, inner: Query) => R | PromiseLike, keyEqualer?: Equaler): AsyncQuery; /** * Creates a subquery for the correlated elements of this [[AsyncQuery]] and another [[AsyncQueryable]]. * * @param inner A [[Queryable]] object. * @param outerKeySelector A callback used to select the key for an element in this [[AsyncQuery]]. * @param innerKeySelector A callback used to select the key for an element in the other Queryable. * @param resultSelector A callback used to select the result for the correlated elements. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Join */ join(inner: AsyncQueryable, outerKeySelector: (element: T) => K, innerKeySelector: (element: I) => K, resultSelector: (outer: T, inner: I) => R | PromiseLike, keyEqualer?: Equaler): AsyncQuery; /** * Creates a subquery for the correlated elements of this [[AsyncQuery]] and another [[AsyncQueryable]]. * * @param inner A [[Queryable]] object. * @param outerKeySelector A callback used to select the key for an element in this [[AsyncQuery]]. * @param innerKeySelector A callback used to select the key for an element in the other Queryable. * @param resultSelector A callback used to select the result for the correlated elements. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Join */ fullJoin(inner: AsyncQueryable, outerKeySelector: (element: T) => K, innerKeySelector: (element: I) => K, resultSelector: (outer: T | undefined, inner: I | undefined) => R | PromiseLike, keyEqualer?: Equaler): AsyncQuery; /** * Creates a subquery that combines this [[AsyncQuery]] with another [[AsyncQueryable]] by combining elements * in tuples. * * @param right An [[AsyncQueryable]] object. * @category Join */ zip(right: AsyncQueryable): AsyncQuery<[T, U]>; /** * Creates a subquery that combines this [[AsyncQuery]] with another [[AsyncQueryable]] by combining elements * using the supplied callback. * * @param right An [[AsyncQueryable]] object. * @param selector A callback used to combine two elements. * @category Join */ zip(right: AsyncQueryable, selector: (left: T, right: U) => R | PromiseLike): AsyncQuery; /** * Creates an ordered subquery whose elements are sorted in ascending order by the provided key. * * @param keySelector A callback used to select the key for an element. * @param comparer An optional callback used to compare two keys. * @category Order */ orderBy(keySelector: (element: T) => K, comparer?: Comparison | Comparer): AsyncOrderedQueryFlow; /** * Creates an ordered subquery whose elements are sorted in descending order by the provided key. * * @param keySelector A callback used to select the key for an element. * @param comparer An optional callback used to compare two keys. * @category Order */ orderByDescending(keySelector: (element: T) => K, comparer?: Comparison | Comparer): AsyncOrderedQueryFlow; /** * Creates a HierarchyQuery using the provided HierarchyProvider. * * @param hierarchy A HierarchyProvider. * @category Hierarchy */ toHierarchy(hierarchy: HierarchyProvider): AsyncHierarchyQueryFlow; /** * Computes a scalar value by applying an accumulator callback over each element. * * @param accumulator the callback used to compute the result. * @category Scalar */ reduce(accumulator: (current: T, element: T, offset: number) => T | PromiseLike): Promise; /** * Computes a scalar value by applying an accumulator callback over each element. * * @param accumulator the callback used to compute the result. * @param seed An optional seed value. * @category Scalar */ reduce(accumulator: (current: U, element: T, offset: number) => U | PromiseLike, seed?: U): Promise; /** * Computes a scalar value by applying an accumulator callback over each element. * * @param accumulator the callback used to compute the result. * @param seed An optional seed value. * @param resultSelector An optional callback used to compute the final result. * @category Scalar */ reduce(accumulator: (current: U, element: T, offset: number) => U | PromiseLike, seed: U, resultSelector: (result: U, count: number) => R | PromiseLike): Promise; /** * Computes a scalar value by applying an accumulator callback over each element in reverse. * * @param accumulator the callback used to compute the result. * @category Scalar */ reduceRight(accumulator: (current: T, element: T, offset: number) => T | PromiseLike): Promise; /** * Computes a scalar value by applying an accumulator callback over each element in reverse. * * @param accumulator the callback used to compute the result. * @param seed An optional seed value. * @category Scalar */ reduceRight(accumulator: (current: U, element: T, offset: number) => U | PromiseLike, seed: U): Promise; /** * Computes a scalar value by applying an accumulator callback over each element in reverse. * * @param accumulator the callback used to compute the result. * @param seed An optional seed value. * @param resultSelector An optional callback used to compute the final result. * @category Scalar */ reduceRight(accumulator: (current: U, element: T, offset: number) => U | PromiseLike, seed: U, resultSelector: (result: U, count: number) => R | PromiseLike): Promise; /** * Counts the number of elements in the Query, optionally filtering elements using the supplied * callback. * * @param predicate An optional callback used to match each element. * @category Scalar */ count(predicate?: (element: T) => boolean | PromiseLike): Promise; /** * Gets the first element in the Query, optionally filtering elements using the supplied * callback. * * @param predicate An optional callback used to match each element. * @category Scalar */ first(predicate: (element: T) => element is U): Promise; /** * Gets the first element in the Query, optionally filtering elements using the supplied * callback. * * @param predicate An optional callback used to match each element. * @category Scalar */ first(predicate?: (element: T) => boolean | PromiseLike): Promise; /** * Gets the last element in the Query, optionally filtering elements using the supplied * callback. * * @param predicate An optional callback used to match each element. * @category Scalar */ last(predicate: (element: T) => element is U): Promise; /** * Gets the last element in the Query, optionally filtering elements using the supplied * callback. * * @param predicate An optional callback used to match each element. * @category Scalar */ last(predicate?: (element: T) => boolean | PromiseLike): Promise; /** * Gets the only element in the Query, or returns undefined. * * @param predicate An optional callback used to match each element. * @category Scalar */ single(predicate: (element: T) => element is U): Promise; /** * Gets the only element in the Query, or returns undefined. * * @param predicate An optional callback used to match each element. * @category Scalar */ single(predicate?: (element: T) => boolean | PromiseLike): Promise; /** * Gets the minimum element in the query, optionally comparing elements using the supplied * callback. * * @param comparer An optional callback used to compare two elements. * @category Scalar */ min(comparer?: Comparison | Comparer): Promise; /** * Gets the minimum element in the query, optionally comparing the keys of each element using the supplied callback. * * @param keySelector A callback used to choose the key to compare. * @param keyComparer An optional callback used to compare the keys. * @category Scalar */ minBy(keySelector: (element: T) => K, keyComparer?: Comparison | Comparer): Promise; /** * Gets the maximum element in the query, optionally comparing elements using the supplied * callback. * * @param comparer An optional callback used to compare two elements. * @category Scalar */ max(comparer?: Comparison | Comparer): Promise; /** * Gets the maximum element in the query, optionally comparing the keys of each element using the supplied callback. * * @param keySelector A callback used to choose the key to compare. * @param keyComparer An optional callback used to compare the keys. * @category Scalar */ maxBy(keySelector: (element: T) => K, keyComparer?: Comparison | Comparer): Promise; /** * Computes the sum for a series of numbers. * * NOTE: If any element is not a `number`, this overload will throw. * * @category Scalar */ sum(): Promise; /** * Computes the sum for a series of numbers. * * @param elementSelector A callback used to convert a value in `source` to a number. * @category Scalar */ sum(elementSelector: (element: T) => number | PromiseLike): Promise; /** * Computes the average for a series of numbers. * * NOTE: If any element is not a `number`, this overload will throw. * * @category Scalar */ average(): Promise; /** * Computes the average for a series of numbers. * * @param elementSelector A callback used to convert a value in `source` to a number. * @category Scalar */ average(elementSelector: (element: T) => number | PromiseLike): Promise; /** * Computes a scalar value indicating whether the Query contains any elements, * optionally filtering the elements using the supplied callback. * * @param predicate An optional callback used to match each element. * @category Scalar */ some(predicate?: (element: T) => boolean | PromiseLike): Promise; /** * Computes a scalar value indicating whether all elements of the Query * match the supplied callback. * * @param predicate A callback used to match each element. * @category Scalar */ every(predicate: (element: T) => boolean | PromiseLike): Promise; /** * Computes a scalar value indicating whether every element in this [[AsyncQuery]] corresponds to a matching element * in another [[AsyncQueryable]] at the same position. * * @param right An [[AsyncQueryable]] object. * @category Scalar */ corresponds(right: AsyncQueryable): Promise; /** * Computes a scalar value indicating whether every element in this [[AsyncQuery]] corresponds to a matching element * in another [[AsyncQueryable]] at the same position. * * @param right An [[AsyncQueryable]] object. * @param equalityComparison An optional callback used to compare the equality of two elements. * @category Scalar */ corresponds(right: AsyncQueryable, equalityComparison: (left: T, right: U) => boolean): Promise; /** * Computes a scalar value indicating whether every element in this [[AsyncQuery]] corresponds to a matching element * in another [[Queryable]] at the same position. * * @param right A [[Queryable]] object. * @param keySelector A callback used to select the key for each element. * @category Scalar */ correspondsBy(right: AsyncQueryable, keySelector: (element: T) => K): Promise; /** * Computes a scalar value indicating whether the key for every element in this [[AsyncQuery]] corresponds to a matching key * in `right` at the same position. * * @param right A [[Queryable]] object. * @param leftKeySelector A callback used to select the key for each element in this [[Query]]. * @param rightKeySelector A callback used to select the key for each element in `right`. * @param keyEqualer An optional callback used to compare the equality of two keys. * @category Scalar */ correspondsBy(right: AsyncQueryable, leftKeySelector: (element: T) => K, rightKeySelector: (element: U) => K, keyEqualer?: EqualityComparison | Equaler): Promise; /** * Computes a scalar value indicating whether the provided value is included in the query. * * @param value A value. * @param equaler An optional callback used to compare the equality of two elements. * @category Scalar */ includes(value: T, equaler?: EqualityComparison | Equaler): Promise; /** * Computes a scalar value indicating whether the provided value is included in the query. * * @param value A value. * @param equaler An optional callback used to compare the equality of two elements. * @category Scalar */ includes(value: U, equaler: (left: T, right: U) => boolean): Promise; /** * Computes a scalar value indicating whether the elements of this [[AsyncQuery]] include * an exact sequence of elements from another [[AsyncQueryable]]. * * @param right An [[AsyncQueryable]] object. * @param equaler A callback used to compare the equality of two elements. * @category Scalar */ includesSequence(right: AsyncQueryable, equaler?: EqualityComparison | Equaler): Promise; /** * Computes a scalar value indicating whether the elements of this [[AsyncQuery]] include * an exact sequence of elements from another [[AsyncQueryable]]. * * @param right An [[AsyncQueryable]] object. * @param equaler A callback used to compare the equality of two elements. * @category Scalar */ includesSequence(right: AsyncQueryable, equaler: (left: T, right: U) => boolean): Promise; /** * Computes a scalar value indicating whether the elements of this [[AsyncQuery]] start * with the same sequence of elements in another [[AsyncQueryable]]. * * @param right An [[AsyncQueryable]] object. * @param equaler A callback used to compare the equality of two elements. * @category Scalar */ startsWith(right: AsyncQueryable, equaler?: EqualityComparison | Equaler): Promise; /** * Computes a scalar value indicating whether the elements of this [[AsyncQuery]] start * with the same sequence of elements in another [[AsyncQueryable]]. * * @param right An [[AsyncQueryable]] object. * @param equaler A callback used to compare the equality of two elements. * @category Scalar */ startsWith(right: AsyncQueryable, equaler: (left: T, right: U) => boolean): Promise; /** * Computes a scalar value indicating whether the elements of this [[AsyncQuery]] end * with the same sequence of elements in another [[AsyncQueryable]]. * * @param right An [[AsyncQueryable]] object. * @param equaler A callback used to compare the equality of two elements. * @category Scalar */ endsWith(right: AsyncQueryable, equaler?: EqualityComparison | Equaler): Promise; /** * Computes a scalar value indicating whether the elements of this [[AsyncQuery]] end * with the same sequence of elements in another [[AsyncQueryable]]. * * @param right An [[AsyncQueryable]] object. * @param equaler A callback used to compare the equality of two elements. * @category Scalar */ endsWith(right: AsyncQueryable, equaler: (left: T, right: U) => boolean): Promise; /** * Finds the value in the Query at the provided offset. A negative offset starts from the * last element. * * @param offset An offset. * @category Scalar */ elementAt(offset: number): Promise; /** * Finds the value in the Query at the provided offset. A negative offset starts from the * last element. * * This is an alias for `elementAt`. * * @param offset An offset. * @category Scalar */ nth(offset: number): Promise; /** * Creates a tuple whose first element is a subquery containing the first span of * elements that match the supplied predicate, and whose second element is a subquery * containing the remaining elements. * * The first subquery is eagerly evaluated, while the second subquery is lazily * evaluated. * * @param predicate The predicate used to match elements. * @category Scalar */ span(predicate: (element: T, offset: number) => element is U): Promise<[Query, AsyncQuery]>; /** * Creates a tuple whose first element is a subquery containing the first span of * elements that match the supplied predicate, and whose second element is a subquery * containing the remaining elements. * * The first subquery is eagerly evaluated, while the second subquery is lazily * evaluated. * * @param predicate The predicate used to match elements. * @category Scalar */ span(predicate: (element: T, offset: number) => boolean | PromiseLike): Promise<[Query, AsyncQuery]>; /** * Creates a tuple whose first element is a subquery containing the first span of * elements that do not match the supplied predicate, and whose second element is a subquery * containing the remaining elements. * * The first subquery is eagerly evaluated, while the second subquery is lazily * evaluated. * * @param predicate The predicate used to match elements. * @category Scalar */ break(predicate: (element: T, offset: number) => boolean | PromiseLike): Promise<[Query, AsyncQuery]>; /** * Invokes a callback for each element of the query. * * @param callback The callback to invoke. * @category Scalar */ forEach(callback: (element: T, offset: number) => void): Promise; /** * Invokes a callback for each element of the query. * * @param callback The callback to invoke. * @category Scalar */ forEach(callback: (element: T, offset: number) => void | PromiseLike): Promise; /** * Iterates over all of the elements in the query, ignoring the results. * @category Scalar */ drain(): Promise; /** * Eagerly evaluate the query, returning a new `Query`. * @category Scalar */ eval(): Promise>; /** * Unzips a sequence of tuples into a tuple of sequences. * @category Scalar */ unzip(): Promise; /** * Unzips a sequence of tuples into a tuple of sequences. * @param partSelector A callback that converts a result into a tuple. * @category Scalar */ unzip(partSelector: (value: T) => U | PromiseLike): Promise<{ [I in keyof U]: U[I][]; }>; /** * Creates an Array for the elements of the Query. * @category Scalar */ toArray(): Promise; /** * Creates an Array for the elements of the Query. * * @param elementSelector A callback that selects a value for each element. * @category Scalar */ toArray(elementSelector: (element: T) => V | PromiseLike): Promise; /** * Creates a `Set` for the elements of the `AsyncQuery`. * @category Scalar */ toSet(): Promise>; /** * Creates a `Set` for the elements of the `AsyncQuery`. * @param equaler An [[Equaler]] object used to compare equality. * @category Scalar */ toSet(equaler: Equaler): Promise>; /** * Creates a `Set` for the elements of the `AsyncQuery`. * * @param elementSelector A callback that selects a value for each element. * @category Scalar */ toSet(elementSelector: (element: T) => V | PromiseLike): Promise>; /** * Creates a `Set` for the elements of the `AsyncQuery`. * * @param elementSelector A callback that selects a value for each element. * @param equaler An [[Equaler]] object used to compare equality. * @category Scalar */ toSet(elementSelector: (element: T) => V | PromiseLike, equaler: Equaler): Promise>; /** * Creates a `Map` for the elements of the `AsyncQuery`. * * @param keySelector A callback used to select a key for each element. * @category Scalar */ toMap(keySelector: (element: T) => K): Promise>; /** * Creates a `Map` for the elements of the `AsyncQuery`. * * @param keySelector A callback used to select a key for each element. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Scalar */ toMap(keySelector: (element: T) => K, keyEqualer: Equaler): Promise>; /** * Creates a `Map` for the elements of the `AsyncQuery`. * * @param keySelector A callback used to select a key for each element. * @param elementSelector A callback that selects a value for each element. * @category Scalar */ toMap(keySelector: (element: T) => K, elementSelector: (element: T) => V | PromiseLike): Promise>; /** * Creates a `Map` for the elements of the `AsyncQuery`. * * @param keySelector A callback used to select a key for each element. * @param elementSelector A callback that selects a value for each element. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Scalar */ toMap(keySelector: (element: T) => K, elementSelector: (element: T) => V | PromiseLike, keyEqualer: Equaler): Promise>; /** * Creates a `Lookup` for the elements of the `Query`. * * @param keySelector A callback used to select a key for each element. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Scalar */ toLookup(keySelector: (element: T) => K, keyEqualer?: Equaler): Promise>; /** * Creates a `Lookup` for the elements of the `Query`. * * @param keySelector A callback used to select a key for each element. * @param elementSelector A callback that selects a value for each element. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Scalar */ toLookup(keySelector: (element: T) => K, elementSelector: (element: T) => V | PromiseLike, keyEqualer?: Equaler): Promise>; /** * Creates an Object for the elements of the [[AsyncQuery]]. Properties are added via `Object.defineProperty`. * * ```ts * // As a regular object * const obj = await fromAsync([Promise.resolve(["x", 1]), ["y", 2]]).toObject(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 = await fromAsync([Promise.resolve(["x", 1]), ["y", 2]]).toObject(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 = await fromAsync([Promise.resolve(["x", 1]), ["y", 2]]).toObject(null, a => a[0]); * obj.x; // ["x", 1] * obj.y; // ["y", 2] * typeof obj.toString; // undefined * ``` * * @param prototype 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. * @param keySelector A callback used to select a key for each element. * @category Scalar */ toObject(prototype: object | null | undefined, keySelector: (element: T) => PropertyKey): Promise; /** * Creates an Object for the elements the [[Query]]. Properties are added via `Object.defineProperty`. * * ```ts * // As a regular object * const obj = await fromAsync([Promise.resolve(["x", 1]), ["y", 2]]).toObject(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 = await fromAsync([Promise.resolve(["x", 1]), ["y", 2]]).toObject(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 = await fromAsync([Promise.resolve(["x", 1]), ["y", 2]]).toObject(null, a => a[0], a => a[1]); * obj.x; // 1 * obj.y; // 2 * typeof obj.toString; // undefined * ``` * * @param prototype 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. * @param keySelector A callback used to select a key for each element. * @param elementSelector A callback that selects a value for each element. * @param descriptorSelector A callback that defines the `PropertyDescriptor` for each property. * @category Scalar */ toObject(prototype: object | null | undefined, keySelector: (element: T) => PropertyKey, elementSelector: (element: T) => V | PromiseLike, descriptorSelector?: (key: PropertyKey, element: V) => PropertyDescriptor): Promise; /** * Writes each element to a destination array. * * @param dest The destination array. * @param start The offset into the array at which to start writing. * @param count The number of elements to write to the array. * @category Scalar */ copyTo>(dest: U, start?: number, count?: number): Promise; } /** * Represents a sequence of hierarchically organized values. */ export declare class AsyncHierarchyQuery extends AsyncQuery implements AsyncHierarchyIterable { constructor(source: PossiblyAsyncHierarchyIterable); constructor(source: AsyncQueryable, hierarchy: HierarchyProvider); /** * Creates a subquery for the roots of each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ root(predicate: (element: TNode) => element is U): AsyncHierarchyQuery; /** * Creates a subquery for the roots of each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ root(predicate?: (element: TNode) => boolean | PromiseLike): AsyncHierarchyQuery; /** * Creates a subquery for the ancestors of each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ ancestors(predicate: (element: TNode) => element is U): AsyncHierarchyQuery; /** * Creates a subquery for the ancestors of each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ ancestors(predicate?: (element: TNode) => boolean | PromiseLike): AsyncHierarchyQuery; /** * Creates a subquery for the ancestors of each element as well as each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ ancestorsAndSelf(predicate: (element: TNode) => element is U): AsyncHierarchyQuery; /** * Creates a subquery for the ancestors of each element as well as each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ ancestorsAndSelf(predicate?: (element: TNode) => boolean | PromiseLike): AsyncHierarchyQuery; /** * Creates a subquery for the descendants of each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ descendants(predicate: (element: TNode) => element is U): AsyncHierarchyQuery; /** * Creates a subquery for the descendants of each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ descendants(predicate?: (element: TNode) => boolean | PromiseLike): AsyncHierarchyQuery; /** * Creates a subquery for the descendants of each element as well as each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ descendantsAndSelf(predicate: (element: TNode) => element is U): AsyncHierarchyQuery; /** * Creates a subquery for the descendants of each element as well as each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ descendantsAndSelf(predicate?: (element: TNode) => boolean | PromiseLike): AsyncHierarchyQuery; /** * Creates a subquery for this [[Asyncquery]]. * * @param predicate A callback used to filter the results. * @category Hierarchy */ self(predicate: (element: TNode) => element is U): AsyncHierarchyQuery; /** * Creates a subquery for this [[Asyncquery]]. * * @param predicate A callback used to filter the results. * @category Hierarchy */ self(predicate: (element: TNode) => element is U): AsyncHierarchyQuery; /** * Creates a subquery for this [[Asyncquery]]. * * @param predicate A callback used to filter the results. * @category Hierarchy */ self(predicate?: (element: TNode) => boolean | PromiseLike): AsyncHierarchyQuery; /** * Creates a subquery for the parents of each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ parents(predicate: (element: TNode) => element is U): AsyncHierarchyQuery; /** * Creates a subquery for the parents of each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ parents(predicate?: (element: TNode) => boolean | PromiseLike): AsyncHierarchyQuery; /** * Creates a subquery for the children of each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ children(predicate: (element: TNode) => element is U): AsyncHierarchyQuery; /** * Creates a subquery for the children of each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ children(predicate?: (element: TNode) => boolean | PromiseLike): AsyncHierarchyQuery; /** * Creates a subquery for the siblings of each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ siblings(predicate: (element: TNode) => element is U): AsyncHierarchyQuery; /** * Creates a subquery for the siblings of each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ siblings(predicate?: (element: TNode) => boolean | PromiseLike): AsyncHierarchyQuery; /** * Creates a subquery for the siblings of each element as well as each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ siblingsAndSelf(predicate: (element: TNode) => element is U): AsyncHierarchyQuery; /** * Creates a subquery for the siblings of each element as well as each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ siblingsAndSelf(predicate?: (element: TNode) => boolean | PromiseLike): AsyncHierarchyQuery; /** * Creates a subquery for the siblings before each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ siblingsBeforeSelf(predicate: (element: TNode) => element is U): AsyncHierarchyQuery; /** * Creates a subquery for the siblings before each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ siblingsBeforeSelf(predicate?: (element: TNode) => boolean | PromiseLike): AsyncHierarchyQuery; /** * Creates a subquery for the siblings after each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ siblingsAfterSelf(predicate: (element: TNode) => element is U): AsyncHierarchyQuery; /** * Creates a subquery for the siblings after each element in the hierarchy. * * @param predicate A callback used to filter the results. * @category Hierarchy */ siblingsAfterSelf(predicate?: (element: TNode) => boolean | PromiseLike): AsyncHierarchyQuery; /** * Creates a subquery for the child of each element at the specified offset. A negative offset * starts from the last child. * * @param offset The offset for the child. * @category Hierarchy */ nthChild(offset: number): AsyncHierarchyQuery; /** * Creates a subquery for the top-most elements. Elements that are a descendant of any other * element are removed. * @category Hierarchy */ topMost(predicate: (element: T) => element is U): AsyncHierarchyQuery; /** * Creates a subquery for the top-most elements. Elements that are a descendant of any other * element are removed. * @category Hierarchy */ topMost(predicate?: (element: T) => boolean | PromiseLike): AsyncHierarchyQuery; /** * Creates a subquery for the bottom-most elements. Elements that are an ancestor of any other * element are removed. * @category Hierarchy */ bottomMost(predicate: (element: T) => element is U): AsyncHierarchyQuery; /** * Creates a subquery for the bottom-most elements. Elements that are an ancestor of any other * element are removed. * @category Hierarchy */ bottomMost(predicate?: (element: T) => boolean | PromiseLike): AsyncHierarchyQuery; [Hierarchical.hierarchy](): HierarchyProvider; } export interface AsyncHierarchyQuery { /** * Creates a subquery for the set intersection of this [[AsyncQuery]] and another [[AsyncQueryable]]. * * @param right A [[Queryable]] object. * @param equaler An [[Equaler]] object used to compare equality. * @category Subquery */ intersect(right: PossiblyAsyncHierarchyIterable, equaler?: Equaler): AsyncHierarchyQuery; /** * Creates a subquery for the set intersection of this [[AsyncQuery]] and another [[AsyncQueryable]]. * * @param right A [[Queryable]] object. * @param equaler An [[Equaler]] object used to compare equality. * @category Subquery */ intersect(right: AsyncQueryable, equaler?: Equaler): AsyncHierarchyQuery; /** * Creates a subquery for the set intersection of this [[AsyncQuery]] and another [[AsyncQueryable]]. * * @param right A [[Queryable]] object. * @param equaler An [[Equaler]] object used to compare equality. * @category Subquery */ intersect(right: AsyncQueryable, equaler?: Equaler): AsyncHierarchyQuery; /** * Creates a subquery for the set intersection of this [[AsyncQuery]] and another [[AsyncQueryable]], where set identity is determined by the selected key. * * @param right A [[Queryable]] object. * @param keySelector A callback used to select the key for each element. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Subquery */ intersectBy(right: PossiblyAsyncHierarchyIterable, keySelector: (element: T) => K, keyEqualer?: Equaler): AsyncHierarchyQuery; /** * Creates a subquery for the set intersection of this [[AsyncQuery]] and another [[AsyncQueryable]], where set identity is determined by the selected key. * * @param right A [[Queryable]] object. * @param keySelector A callback used to select the key for each element. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Subquery */ intersectBy(right: AsyncQueryable, keySelector: (element: T) => K, keyEqualer?: Equaler): AsyncHierarchyQuery; /** * Creates a subquery for the set intersection of this [[AsyncQuery]] and another [[AsyncQueryable]], where set identity is determined by the selected key. * * @param right A [[Queryable]] object. * @param keySelector A callback used to select the key for each element. * @param keyEqualer An [[Equaler]] object used to compare key equality. * @category Subquery */ intersectBy(right: AsyncQueryable, keySelector: (element: T) => K, keyEqualer?: Equaler): AsyncHierarchyQuery; } /** * Represents an ordered sequence of elements. */ export declare class AsyncOrderedQuery extends AsyncQuery implements AsyncOrderedIterable { constructor(source: PossiblyAsyncOrderedIterable); /** * Creates a subsequent ordered subquery whose elements are sorted in ascending order by the provided key. * * @param keySelector A callback used to select the key for an element. * @param comparer An optional callback used to compare two keys. * @category Order */ thenBy(keySelector: (element: T) => K, comparer?: Comparison | Comparer): AsyncOrderedQuery; /** * Creates a subsequent ordered subquery whose elements are sorted in descending order by the provided key. * * @param keySelector A callback used to select the key for an element. * @param comparer An optional callback used to compare two keys. * @category Order */ thenByDescending(keySelector: (element: T) => K, comparer?: Comparison | Comparer): AsyncOrderedQuery; [AsyncOrderedIterable.thenByAsync](keySelector: (element: T) => K, comparer: Comparison | Comparer, descending: boolean): AsyncOrderedIterable; } /** * Represents an ordered sequence of hierarchically organized values. */ export declare class AsyncOrderedHierarchyQuery extends AsyncHierarchyQuery implements AsyncOrderedHierarchyIterable { constructor(source: PossiblyAsyncOrderedHierarchyIterable); constructor(source: PossiblyAsyncOrderedIterable, hierarchy: HierarchyProvider); /** * Creates a subsequent ordered subquery whose elements are sorted in ascending order by the provided key. * * @param keySelector A callback used to select the key for an element. * @param comparison An optional callback used to compare two keys. * @category Order */ thenBy(keySelector: (element: T) => K, comparison?: Comparison | Comparer): AsyncOrderedHierarchyQuery; /** * Creates a subsequent ordered subquery whose elements are sorted in descending order by the provided key. * * @param keySelector A callback used to select the key for an element. * @param comparison An optional callback used to compare two keys. * @category Order */ thenByDescending(keySelector: (element: T) => K, comparison?: Comparison | Comparer): AsyncOrderedHierarchyQuery; [AsyncOrderedIterable.thenByAsync](keySelector: (element: T) => K, comparison: Comparison | Comparer, descending: boolean): AsyncOrderedHierarchyIterable; } //# sourceMappingURL=asyncQuery.d.ts.map