/*!
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 "./compat";
import { Comparison, Comparer } from '@esfx/equatable';
/**
* Typed key-value pairs derived from the properties of an `object`.
*/
export declare type KeyValuePair = K extends keyof T ? [K, T[K]] : never;
/**
* Describes an object that defines the relationships between parents and children of an element.
*/
export interface HierarchyProvider {
/**
* Indicates whether the supplied element is contained within a hierarchy.
*/
owns?(element: TNode): boolean;
/**
* Gets the parent element for the supplied element.
*/
parent(element: TNode): TNode | undefined;
/**
* Gets the children elements for the supplied element.
*/
children(element: TNode): Queryable | undefined;
}
/**
* Describes an object that has a navigable hierarchy.
*/
export interface Hierarchical {
/**
* Gets an object that provides hierarchical relationships.
*/
[Hierarchical.hierarchy](): HierarchyProvider;
}
export declare namespace Hierarchical {
/** @ignore */
const hierarchy: unique symbol;
}
export { Comparable } from "@esfx/equatable";
export { Equatable } from "@esfx/equatable";
/**
* Represents a group of values associated with the same key.
*/
export interface Grouping extends Iterable {
/**
* The key associated with this group.
*
* NOTE: This is a convenience alias for [Grouping.key] and should return the same value.
*/
readonly key: K;
/**
* The key associated with this group.
*
* NOTE: This is a convenience alias for the values in the grouping and should return the same values.
*/
readonly values: Iterable;
/**
* The key associated with this group.
*/
readonly [Grouping.key]: K;
}
export declare namespace Grouping {
const key: unique symbol;
}
/**
* Represents a group of hierarchical values associated with the same key.
*/
export interface HierarchyGrouping extends Grouping, HierarchyIterable {
}
/**
* Represents a page of values.
*/
export interface Page extends Iterable {
/**
* The page offset from the start of the source iterable.
*
* NOTE: This is a convenience alias for [Page.page] and should return the same value.
*/
readonly page: number;
/**
* The element offset from the start of the source iterable.
*
* NOTE: This is a convenience alias for [Page.offset] and should return the same value.
*/
readonly offset: number;
/**
* The page offset from the start of the source iterable.
*/
readonly [Page.page]: number;
/**
* The element offset from the start of the source iterable.
*/
readonly [Page.offset]: number;
}
export declare namespace Page {
const page: unique symbol;
const offset: unique symbol;
}
/**
* Represents a page of hierarchical values.
*/
export interface HierarchyPage extends Page, HierarchyIterable {
}
/**
* Represents an [[Iterable]] that is inherently ordered.
*/
export interface OrderedIterable extends Iterable {
/**
* Creates a subsequent `OrderedIterable` whose elements are also ordered by the provided key.
* @param keySelector A callback used to select the key for an element.
* @param comparer A callback used to compare two keys.
* @param descending A value indicating whether to sort in descending (`true`) or ascending (`false`) order.
*/
[OrderedIterable.thenBy](keySelector: (element: T) => K, comparer: Comparison | Comparer, descending: boolean): OrderedIterable;
}
export declare namespace OrderedIterable {
/** @ignore */
const thenBy: unique symbol;
}
/**
* Represents an [[Iterable]] with a navigable hierarchy.
*/
export interface HierarchyIterable extends Iterable, Hierarchical {
}
/**
* Represents an [[Iterable]] with a navigable hierarchy that is inherently ordered.
*/
export interface OrderedHierarchyIterable extends OrderedIterable, HierarchyIterable {
}
export declare type Choice = [K, Queryable];
/**
* Represents an [[AsyncIterable]] that is inherently ordered.
*/
export interface AsyncOrderedIterable extends AsyncIterable {
/**
* Creates a subsequent `AsyncOrderedIterable` whose elements are also ordered 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.
* @param descending A value indicating whether to sort in descending (`true`) or ascending (`false`) order.
*/
[AsyncOrderedIterable.thenByAsync](keySelector: (element: T) => K, comparer: Comparison | Comparer, descending: boolean): AsyncOrderedIterable;
}
export declare namespace AsyncOrderedIterable {
const thenByAsync: unique symbol;
}
/**
* Represents an [[AsyncIterable]] with a navigable hierarchy.
*/
export interface AsyncHierarchyIterable extends AsyncIterable, Hierarchical {
}
/**
* Represents an [[AsyncIterable]] with a navigable hierarchy that is inherently ordered.
*/
export interface AsyncOrderedHierarchyIterable extends AsyncOrderedIterable, AsyncHierarchyIterable {
}
export declare type AsyncChoice = [PromiseLike | K, AsyncQueryable];
export declare type Queryable = Iterable | ArrayLike;
export declare type AsyncQueryable = AsyncIterable | Queryable | T>;
export declare type PossiblyAsyncIterable = AsyncIterable | Iterable | T>;
export declare type PossiblyAsyncHierarchyIterable = AsyncHierarchyIterable | HierarchyIterable;
export declare type PossiblyAsyncOrderedIterable = AsyncOrderedIterable | OrderedIterable;
export declare type PossiblyAsyncOrderedHierarchyIterable = AsyncOrderedHierarchyIterable | OrderedHierarchyIterable;
export declare type QueriedType = T extends Queryable ? U : never;
export interface WritableArrayLike {
[index: number]: T;
length: number;
}
//# sourceMappingURL=types.d.ts.map