Comparing version 0.0.2 to 0.0.3
declare global { | ||
interface Generator<T = unknown, TReturn = any, TNext = unknown> { | ||
/** | ||
* Produces the set intersection of two sequences by using | ||
* the default equality comparer to compare values. | ||
* @param that A sequence whose distinct elements that also appear in the first sequence will be returned. | ||
* @returns A sequence that contains the elements that form the set intersection of two sequences. | ||
*/ | ||
intersect(this: Generator<number, TReturn, TNext>, that: Generator<number, TReturn, TNext> | number[]): Generator<number, TReturn, TNext>; | ||
/** | ||
* Produces the set intersection of two sequences by using | ||
* the default equality comparer to compare values. | ||
* @param that A sequence whose distinct elements that also appear in the first sequence will be returned. | ||
* @returns A sequence that contains the elements that form the set intersection of two sequences. | ||
*/ | ||
intersect(this: Generator<string, TReturn, TNext>, that: Generator<string, TReturn, TNext> | string[]): Generator<string, TReturn, TNext>; | ||
/** | ||
* Produces the set intersection of two sequences by using | ||
* the default equality comparer to compare values. | ||
* @param that A sequence whose distinct elements that also appear in the first sequence will be returned. | ||
* @returns A sequence that contains the elements that form the set intersection of two sequences. | ||
*/ | ||
intersect(this: Generator<boolean, TReturn, TNext>, that: Generator<boolean, TReturn, TNext> | boolean[]): Generator<boolean, TReturn, TNext>; | ||
/** | ||
* Produces the set intersection of two sequences by using | ||
* the specified comparitor to compare values. | ||
* @param that A sequence whose distinct elements that also appear in the first sequence will be returned. | ||
* @param comparitor A comparitor to compare values. | ||
* @returns A sequence that contains the elements that form the set intersection of two sequences. | ||
*/ | ||
intersect(that: Generator<T, TReturn, TNext> | T[], comparitor: (a: T, b: T) => boolean): Generator<T, TReturn, TNext>; | ||
} | ||
interface AsyncGenerator<T = unknown, TReturn = any, TNext = unknown> { | ||
/** | ||
* Produces the set intersection of two sequences by using | ||
* the default equality comparer to compare values. | ||
* @param that A sequence whose distinct elements that also appear in the first sequence will be returned. | ||
* @returns A sequence that contains the elements that form the set intersection of two sequences. | ||
*/ | ||
intersect(this: AsyncGenerator<number, TReturn, TNext>, that: AsyncGenerator<number, TReturn, TNext> | Generator<number, TReturn, TNext> | number[]): AsyncGenerator<number, TReturn, TNext>; | ||
/** | ||
* Produces the set intersection of two sequences by using | ||
* the default equality comparer to compare values. | ||
* @param that A sequence whose distinct elements that also appear in the first sequence will be returned. | ||
* @returns A sequence that contains the elements that form the set intersection of two sequences. | ||
*/ | ||
intersect(this: AsyncGenerator<string, TReturn, TNext>, that: AsyncGenerator<string, TReturn, TNext> | Generator<string, TReturn, TNext> | string[]): AsyncGenerator<string, TReturn, TNext>; | ||
/** | ||
* Produces the set intersection of two sequences by using | ||
* the default equality comparer to compare values. | ||
* @param that A sequence whose distinct elements that also appear in the first sequence will be returned. | ||
* @returns A sequence that contains the elements that form the set intersection of two sequences. | ||
*/ | ||
intersect(this: AsyncGenerator<boolean, TReturn, TNext>, that: AsyncGenerator<boolean, TReturn, TNext> | Generator<boolean, TReturn, TNext> | boolean[]): AsyncGenerator<boolean, TReturn, TNext>; | ||
/** | ||
* Produces the set intersection of two sequences by using | ||
* the specified comparitor to compare values. | ||
* @param that A sequence whose distinct elements that also appear in the first sequence will be returned. | ||
* @param comparitor A comparitor to compare values. | ||
* @returns A sequence that contains the elements that form the set intersection of two sequences. | ||
*/ | ||
intersect(that: AsyncGenerator<T, TReturn, TNext> | Generator<T, TReturn, TNext> | T[], comparitor: (a: T, b: T) => boolean): AsyncGenerator<T, TReturn, TNext>; | ||
@@ -13,0 +63,0 @@ } |
@@ -5,9 +5,47 @@ import "./array"; | ||
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>; | ||
} | ||
} |
@@ -5,15 +5,68 @@ import "./array"; | ||
interface Generator<T = unknown, TReturn = any, TNext = unknown> { | ||
/** | ||
* Returns the last element of a sequence. | ||
* @returns The value at the last position in the source sequence. | ||
*/ | ||
last(): T; | ||
/** | ||
* Returns the last element of a sequence that satisfies a specified condition. | ||
* @param predicate A function to test each element for a condition. | ||
* @returns The last element in the sequence that passes the test in the specified predicate function. | ||
*/ | ||
last(predicate: (item: T) => boolean): T; | ||
/** | ||
* Returns the last element of a sequence that matches the specified type. | ||
* @param predicate A type checker function to test each element for a condition. | ||
* @returns The last element in the sequence that matches the specified type. | ||
*/ | ||
last<TResult extends T>(predicate: (item: T) => item is TResult): TResult; | ||
/** | ||
* Returns the last element of a sequence, or undefined if the sequence contains no elements. | ||
* @param allow_undefined Specify that undefined should be returned if no elements. | ||
* @returns undefined if the source sequence is empty; otherwise, the last element in the sequence. | ||
*/ | ||
last(allow_undefined: "or-default"): T | undefined; | ||
/** | ||
* Returns the last element of a sequence that satisfies a | ||
* condition or undefined if no such element is found. | ||
* @param predicate A function to test each element for a condition. | ||
* @param allow_undefined Specify that undefined should be returned if no elements. | ||
* @returns undefined if the sequence is empty or if no elements pass the test in the predicate function; otherwise, the last element that passes the test in the predicate function. | ||
*/ | ||
last(predicate: (item: T) => boolean, allow_undefined: "or-default"): T | undefined; | ||
/** | ||
* Returns the last element of a sequence that matches the type provided or undefined if no such element is found. | ||
* @param predicate A type checker function to test each element for a condition. | ||
* @param allow_undefined Specify that undefined should be returned if no elements. | ||
* @returns undefined if the sequence is empty or if no elements pass the test in the predicate function; otherwise, the last element that matches the type provided. | ||
*/ | ||
last<TResult extends T>(predicate: (item: T) => item is TResult, allow_undefined: "or-default"): TResult | undefined; | ||
} | ||
interface AsyncGenerator<T = unknown, TReturn = any, TNext = unknown> { | ||
/** | ||
* Returns the last element of a sequence. | ||
* @returns The value at the last position in the source sequence. | ||
*/ | ||
last(): Promise<T>; | ||
/** | ||
* Returns the last element of a sequence that satisfies a specified condition. | ||
* @param predicate A function to test each element for a condition. | ||
* @returns The last element in the sequence that passes the test in the specified predicate function. | ||
*/ | ||
last(predicate: (item: T) => Promised<boolean>): Promise<T>; | ||
/** | ||
* Returns the last element of a sequence, or undefined if the sequence contains no elements. | ||
* @param allow_undefined Specify that undefined should be returned if no elements. | ||
* @returns undefined if the source sequence is empty; otherwise, the last element in the sequence. | ||
*/ | ||
last(allow_undefined: "or-default"): Promise<T | undefined>; | ||
/** | ||
* Returns the last element of a sequence that satisfies a | ||
* condition or undefined if no such element is found. | ||
* @param predicate A function to test each element for a condition. | ||
* @param allow_undefined Specify that undefined should be returned if no elements. | ||
* @returns undefined if the sequence is empty or if no elements pass the test in the predicate function; otherwise, the last element that passes the test in the predicate function. | ||
*/ | ||
last(predicate: (item: T) => Promised<boolean>, allow_undefined: "or-default"): Promise<T | undefined>; | ||
} | ||
} |
@@ -6,9 +6,29 @@ import { Promised } from "./utils"; | ||
interface Generator<T = unknown, TReturn = any, TNext = unknown> { | ||
/** | ||
* Returns the maximum value in a sequence of number values. | ||
* @returns The maximum value in the sequence. | ||
*/ | ||
max(this: Generator<number, TReturn, TNext>): number; | ||
/** | ||
* Invokes a transform function on each element of a generic | ||
* sequence and returns the maximum resulting value. | ||
* @param selector A transform function to apply to each element. | ||
* @returns The maximum value in the sequence. | ||
*/ | ||
max(selector: (item: T) => number): number; | ||
} | ||
interface AsyncGenerator<T = unknown, TReturn = any, TNext = unknown> { | ||
/** | ||
* Returns the maximum value in a sequence of number values. | ||
* @returns The maximum value in the sequence. | ||
*/ | ||
max(this: Generator<number, TReturn, TNext>): Promise<number>; | ||
/** | ||
* Invokes a transform function on each element of a generic | ||
* sequence and returns the maximum resulting value. | ||
* @param selector A transform function to apply to each element. | ||
* @returns The maximum value in the sequence. | ||
*/ | ||
max(selector: (item: T) => Promised<number>): Promise<number>; | ||
} | ||
} |
@@ -6,9 +6,29 @@ import { Promised } from "./utils"; | ||
interface Generator<T = unknown, TReturn = any, TNext = unknown> { | ||
/** | ||
* Returns the minimum value in a sequence of number values. | ||
* @returns The minimum value in the sequence. | ||
*/ | ||
min(this: Generator<number, TReturn, TNext>): number; | ||
/** | ||
* Invokes a transform function on each element of a generic | ||
* sequence and returns the minimum resulting value. | ||
* @param selector A transform function to apply to each element. | ||
* @returns The minimum value in the sequence. | ||
*/ | ||
min(selector: (item: T) => number): number; | ||
} | ||
interface AsyncGenerator<T = unknown, TReturn = any, TNext = unknown> { | ||
/** | ||
* Returns the minimum value in a sequence of number values. | ||
* @returns The minimum value in the sequence. | ||
*/ | ||
min(this: Generator<number, TReturn, TNext>): Promise<number>; | ||
/** | ||
* Invokes a transform function on each element of a generic | ||
* sequence and returns the minimum resulting value. | ||
* @param selector A transform function to apply to each element. | ||
* @returns The minimum value in the sequence. | ||
*/ | ||
min(selector: (item: T) => Promised<number>): Promise<number>; | ||
} | ||
} |
@@ -30,2 +30,4 @@ "use strict"; | ||
gen[key] = function (...args) { | ||
if (!IsSync(this) && !IsAsync(this)) | ||
return; | ||
return (0, safe_type_1.PatternMatch)(IsSync, IsAsync)((s) => sync_handler.bind(s, ...args)(), (a) => async_handler.bind(a, ...args)())(this); | ||
@@ -32,0 +34,0 @@ }; |
{ | ||
"name": "geninq", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A JavaScript version of the Linq library for Generators", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -5,2 +5,8 @@ import { Build } from "./utils"; | ||
interface Generator<T = unknown, TReturn = any, TNext = unknown> { | ||
/** | ||
* Produces the set intersection of two sequences by using | ||
* the default equality comparer to compare values. | ||
* @param that A sequence whose distinct elements that also appear in the first sequence will be returned. | ||
* @returns A sequence that contains the elements that form the set intersection of two sequences. | ||
*/ | ||
intersect( | ||
@@ -10,2 +16,8 @@ this: Generator<number, TReturn, TNext>, | ||
): Generator<number, TReturn, TNext>; | ||
/** | ||
* Produces the set intersection of two sequences by using | ||
* the default equality comparer to compare values. | ||
* @param that A sequence whose distinct elements that also appear in the first sequence will be returned. | ||
* @returns A sequence that contains the elements that form the set intersection of two sequences. | ||
*/ | ||
intersect( | ||
@@ -15,2 +27,8 @@ this: Generator<string, TReturn, TNext>, | ||
): Generator<string, TReturn, TNext>; | ||
/** | ||
* Produces the set intersection of two sequences by using | ||
* the default equality comparer to compare values. | ||
* @param that A sequence whose distinct elements that also appear in the first sequence will be returned. | ||
* @returns A sequence that contains the elements that form the set intersection of two sequences. | ||
*/ | ||
intersect( | ||
@@ -20,2 +38,9 @@ this: Generator<boolean, TReturn, TNext>, | ||
): Generator<boolean, TReturn, TNext>; | ||
/** | ||
* Produces the set intersection of two sequences by using | ||
* the specified comparitor to compare values. | ||
* @param that A sequence whose distinct elements that also appear in the first sequence will be returned. | ||
* @param comparitor A comparitor to compare values. | ||
* @returns A sequence that contains the elements that form the set intersection of two sequences. | ||
*/ | ||
intersect( | ||
@@ -28,2 +53,8 @@ that: Generator<T, TReturn, TNext> | T[], | ||
interface AsyncGenerator<T = unknown, TReturn = any, TNext = unknown> { | ||
/** | ||
* Produces the set intersection of two sequences by using | ||
* the default equality comparer to compare values. | ||
* @param that A sequence whose distinct elements that also appear in the first sequence will be returned. | ||
* @returns A sequence that contains the elements that form the set intersection of two sequences. | ||
*/ | ||
intersect( | ||
@@ -36,2 +67,8 @@ this: AsyncGenerator<number, TReturn, TNext>, | ||
): AsyncGenerator<number, TReturn, TNext>; | ||
/** | ||
* Produces the set intersection of two sequences by using | ||
* the default equality comparer to compare values. | ||
* @param that A sequence whose distinct elements that also appear in the first sequence will be returned. | ||
* @returns A sequence that contains the elements that form the set intersection of two sequences. | ||
*/ | ||
intersect( | ||
@@ -44,2 +81,8 @@ this: AsyncGenerator<string, TReturn, TNext>, | ||
): AsyncGenerator<string, TReturn, TNext>; | ||
/** | ||
* Produces the set intersection of two sequences by using | ||
* the default equality comparer to compare values. | ||
* @param that A sequence whose distinct elements that also appear in the first sequence will be returned. | ||
* @returns A sequence that contains the elements that form the set intersection of two sequences. | ||
*/ | ||
intersect( | ||
@@ -52,2 +95,9 @@ this: AsyncGenerator<boolean, TReturn, TNext>, | ||
): AsyncGenerator<boolean, TReturn, TNext>; | ||
/** | ||
* Produces the set intersection of two sequences by using | ||
* the specified comparitor to compare values. | ||
* @param that A sequence whose distinct elements that also appear in the first sequence will be returned. | ||
* @param comparitor A comparitor to compare values. | ||
* @returns A sequence that contains the elements that form the set intersection of two sequences. | ||
*/ | ||
intersect( | ||
@@ -54,0 +104,0 @@ that: |
@@ -6,2 +6,11 @@ import "./array"; | ||
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>( | ||
@@ -13,2 +22,12 @@ inner: Generator<TInner> | TInner[], | ||
): 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>( | ||
@@ -24,2 +43,11 @@ inner: Generator<TInner> | TInner[], | ||
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>( | ||
@@ -31,2 +59,12 @@ inner: AsyncGenerator<TInner> | Generator<TInner> | TInner[], | ||
): 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>( | ||
@@ -33,0 +71,0 @@ inner: AsyncGenerator<TInner> | Generator<TInner> | TInner[], |
@@ -7,6 +7,32 @@ import { IsString } from "@paulpopat/safe-type"; | ||
interface Generator<T = unknown, TReturn = any, TNext = unknown> { | ||
/** | ||
* Returns the last element of a sequence. | ||
* @returns The value at the last position in the source sequence. | ||
*/ | ||
last(): T; | ||
/** | ||
* Returns the last element of a sequence that satisfies a specified condition. | ||
* @param predicate A function to test each element for a condition. | ||
* @returns The last element in the sequence that passes the test in the specified predicate function. | ||
*/ | ||
last(predicate: (item: T) => boolean): T; | ||
/** | ||
* Returns the last element of a sequence that matches the specified type. | ||
* @param predicate A type checker function to test each element for a condition. | ||
* @returns The last element in the sequence that matches the specified type. | ||
*/ | ||
last<TResult extends T>(predicate: (item: T) => item is TResult): TResult; | ||
/** | ||
* Returns the last element of a sequence, or undefined if the sequence contains no elements. | ||
* @param allow_undefined Specify that undefined should be returned if no elements. | ||
* @returns undefined if the source sequence is empty; otherwise, the last element in the sequence. | ||
*/ | ||
last(allow_undefined: "or-default"): T | undefined; | ||
/** | ||
* Returns the last element of a sequence that satisfies a | ||
* condition or undefined if no such element is found. | ||
* @param predicate A function to test each element for a condition. | ||
* @param allow_undefined Specify that undefined should be returned if no elements. | ||
* @returns undefined if the sequence is empty or if no elements pass the test in the predicate function; otherwise, the last element that passes the test in the predicate function. | ||
*/ | ||
last( | ||
@@ -16,2 +42,8 @@ predicate: (item: T) => boolean, | ||
): T | undefined; | ||
/** | ||
* Returns the last element of a sequence that matches the type provided or undefined if no such element is found. | ||
* @param predicate A type checker function to test each element for a condition. | ||
* @param allow_undefined Specify that undefined should be returned if no elements. | ||
* @returns undefined if the sequence is empty or if no elements pass the test in the predicate function; otherwise, the last element that matches the type provided. | ||
*/ | ||
last<TResult extends T>( | ||
@@ -24,5 +56,26 @@ predicate: (item: T) => item is TResult, | ||
interface AsyncGenerator<T = unknown, TReturn = any, TNext = unknown> { | ||
/** | ||
* Returns the last element of a sequence. | ||
* @returns The value at the last position in the source sequence. | ||
*/ | ||
last(): Promise<T>; | ||
/** | ||
* Returns the last element of a sequence that satisfies a specified condition. | ||
* @param predicate A function to test each element for a condition. | ||
* @returns The last element in the sequence that passes the test in the specified predicate function. | ||
*/ | ||
last(predicate: (item: T) => Promised<boolean>): Promise<T>; | ||
/** | ||
* Returns the last element of a sequence, or undefined if the sequence contains no elements. | ||
* @param allow_undefined Specify that undefined should be returned if no elements. | ||
* @returns undefined if the source sequence is empty; otherwise, the last element in the sequence. | ||
*/ | ||
last(allow_undefined: "or-default"): Promise<T | undefined>; | ||
/** | ||
* Returns the last element of a sequence that satisfies a | ||
* condition or undefined if no such element is found. | ||
* @param predicate A function to test each element for a condition. | ||
* @param allow_undefined Specify that undefined should be returned if no elements. | ||
* @returns undefined if the sequence is empty or if no elements pass the test in the predicate function; otherwise, the last element that passes the test in the predicate function. | ||
*/ | ||
last( | ||
@@ -29,0 +82,0 @@ predicate: (item: T) => Promised<boolean>, |
@@ -7,3 +7,13 @@ import { Build, Promised } from "./utils"; | ||
interface Generator<T = unknown, TReturn = any, TNext = unknown> { | ||
/** | ||
* Returns the maximum value in a sequence of number values. | ||
* @returns The maximum value in the sequence. | ||
*/ | ||
max(this: Generator<number, TReturn, TNext>): number; | ||
/** | ||
* Invokes a transform function on each element of a generic | ||
* sequence and returns the maximum resulting value. | ||
* @param selector A transform function to apply to each element. | ||
* @returns The maximum value in the sequence. | ||
*/ | ||
max(selector: (item: T) => number): number; | ||
@@ -13,3 +23,13 @@ } | ||
interface AsyncGenerator<T = unknown, TReturn = any, TNext = unknown> { | ||
/** | ||
* Returns the maximum value in a sequence of number values. | ||
* @returns The maximum value in the sequence. | ||
*/ | ||
max(this: Generator<number, TReturn, TNext>): Promise<number>; | ||
/** | ||
* Invokes a transform function on each element of a generic | ||
* sequence and returns the maximum resulting value. | ||
* @param selector A transform function to apply to each element. | ||
* @returns The maximum value in the sequence. | ||
*/ | ||
max(selector: (item: T) => Promised<number>): Promise<number>; | ||
@@ -16,0 +36,0 @@ } |
@@ -7,3 +7,13 @@ import { Build, Promised } from "./utils"; | ||
interface Generator<T = unknown, TReturn = any, TNext = unknown> { | ||
/** | ||
* Returns the minimum value in a sequence of number values. | ||
* @returns The minimum value in the sequence. | ||
*/ | ||
min(this: Generator<number, TReturn, TNext>): number; | ||
/** | ||
* Invokes a transform function on each element of a generic | ||
* sequence and returns the minimum resulting value. | ||
* @param selector A transform function to apply to each element. | ||
* @returns The minimum value in the sequence. | ||
*/ | ||
min(selector: (item: T) => number): number; | ||
@@ -13,3 +23,13 @@ } | ||
interface AsyncGenerator<T = unknown, TReturn = any, TNext = unknown> { | ||
/** | ||
* Returns the minimum value in a sequence of number values. | ||
* @returns The minimum value in the sequence. | ||
*/ | ||
min(this: Generator<number, TReturn, TNext>): Promise<number>; | ||
/** | ||
* Invokes a transform function on each element of a generic | ||
* sequence and returns the minimum resulting value. | ||
* @param selector A transform function to apply to each element. | ||
* @returns The minimum value in the sequence. | ||
*/ | ||
min(selector: (item: T) => Promised<number>): Promise<number>; | ||
@@ -16,0 +36,0 @@ } |
@@ -6,4 +6,2 @@ import { Build, Promised } from "./utils"; | ||
Assert, | ||
DoNotCare, | ||
IsArray, | ||
IsFunction, | ||
@@ -10,0 +8,0 @@ IsNumber, |
@@ -37,2 +37,4 @@ import { PatternMatch } from "@paulpopat/safe-type"; | ||
gen[key] = function (...args: Parameters<Gen[TKey]>) { | ||
if (!IsSync(this) && !IsAsync(this)) return; | ||
return PatternMatch(IsSync, IsAsync)( | ||
@@ -39,0 +41,0 @@ (s) => (sync_handler as any).bind(s, ...args)(), |
303718
7225
178