geninq
Version:
A JavaScript version of the Linq library for Generators
51 lines (50 loc) • 4.28 kB
TypeScript
import "./array";
import { Promised } from "./utils";
declare global {
interface Generator<T = unknown, TReturn = any, TNext = unknown> {
/**
* Correlates the elements of two sequences based on matching keys.
* The default equality comparer is used to compare keys.
* @param inner The sequence to join to the first sequence.
* @param outer_key_selector A function to extract the join key from each element of this sequence.
* @param inner_key_selector A function to extract the join key from each element of the inner sequence.
* @param result_selector A function to create a result element from two matching elements.
* @returns A sequence that has elements of type TResult that are obtained by performing an inner join on two sequences.
*/
join<TKey extends string | number | boolean, TInner, TResult>(inner: Generator<TInner> | TInner[], outer_key_selector: (item: T) => TKey, inner_key_selector: (item: TInner) => TKey, result_selector: (out: T, inn: TInner) => TResult): Generator<TResult>;
/**
* Correlates the elements of two sequences based on matching keys.
* A specified comparitor is used to compare keys.
* @param inner The sequence to join to the first sequence.
* @param outer_key_selector A function to extract the join key from each element of this sequence.
* @param inner_key_selector A function to extract the join key from each element of the inner sequence.
* @param result_selector A function to create a result element from two matching elements.
* @param comparitor A comparitor to hash and compare keys.
* @returns A sequence that has elements of type TResult that are obtained by performing an inner join on two sequences.
*/
join<TKey, TInner, TResult>(inner: Generator<TInner> | TInner[], outer_key_selector: (item: T) => TKey, inner_key_selector: (item: TInner) => TKey, result_selector: (out: T, inn: TInner) => TResult, comparitor: (a: TKey, b: TKey) => boolean): Generator<TResult>;
}
interface AsyncGenerator<T = unknown, TReturn = any, TNext = unknown> {
/**
* Correlates the elements of two sequences based on matching keys.
* The default equality comparer is used to compare keys.
* @param inner The sequence to join to the first sequence.
* @param outer_key_selector A function to extract the join key from each element of this sequence.
* @param inner_key_selector A function to extract the join key from each element of the inner sequence.
* @param result_selector A function to create a result element from two matching elements.
* @returns A sequence that has elements of type TResult that are obtained by performing an inner join on two sequences.
*/
join<TKey extends string | number | boolean, TInner, TResult>(inner: AsyncGenerator<TInner> | Generator<TInner> | TInner[], outer_key_selector: (item: T) => Promised<TKey>, inner_key_selector: (item: TInner) => Promised<TKey>, result_selector: (out: T, inn: TInner) => Promised<TResult>): AsyncGenerator<TResult>;
/**
* Correlates the elements of two sequences based on matching keys.
* A specified comparitor is used to compare keys.
* @param inner The sequence to join to the first sequence.
* @param outer_key_selector A function to extract the join key from each element of this sequence.
* @param inner_key_selector A function to extract the join key from each element of the inner sequence.
* @param result_selector A function to create a result element from two matching elements.
* @param comparitor A comparitor to hash and compare keys.
* @returns A sequence that has elements of type TResult that are obtained by performing an inner join on two sequences.
*/
join<TKey, TInner, TResult>(inner: AsyncGenerator<TInner> | Generator<TInner> | TInner[], outer_key_selector: (item: T) => Promised<TKey>, inner_key_selector: (item: TInner) => Promised<TKey>, result_selector: (out: T, inn: TInner) => Promised<TResult>, comparitor: (a: TKey, b: TKey) => boolean): AsyncGenerator<TResult>;
}
}