import { AsyncPredicate, Predicate } from 'augmentative-iterable'; export interface LastFunction { /** * Returns the last element of the iterable matching a predicate, or `undefined` value if no such element is found. This is a resolving operation, will cause a full loop through all the elements of the iterable.
* Examples:
* * `fluent(['anchor', 'almond', 'bound', 'alpine']).last()` returns *alpine*
* * `fluent([]).last()` returns `undefined`
* * `fluent(['anchor', 'almond', 'bound', 'alpine']).last(word => word[0] === 'b')` returns *bound*
* * `fluent(['anchor', 'almond', 'bound', 'alpine']).last(word => word[0] === 'c')` returns `undefined` * @param predicate The last element is to be returned which matches this predicate. Defaults to the always true function and thus, returns the last element in the iterable if omitted. * @returns The last element matching the specified predicate, or `undefined` if no such element found. */ (predicate?: Predicate): T | undefined; /** * Returns the last element of the iterable matching a predicate, or `undefined` value if no such element is found. This is a resolving operation, will cause a full loop through all the elements of the iterable.
* Examples:
* * `fluent(['anchor', 'almond', 'bound', 'alpine']).last()` returns *alpine*
* * `fluent([]).last()` returns `undefined`
* * `fluent(['anchor', 'almond', 'bound', 'alpine']).last(word => word[0] === 'b')` returns *bound*
* * `fluent(['anchor', 'almond', 'bound', 'alpine']).last(word => word[0] === 'c')` returns `undefined` * @param predicate The last element is to be returned which matches this predicate. Defaults to the always true function and thus, returns the last element in the iterable if omitted. * @returns The last element matching the specified predicate, or `undefined` if no such element found. */ (predicate: keyof T): T | undefined; } export interface AsyncLastFunction { /** * Returns the last element of the iterable matching an asynchronous predicate, or `undefined` value if no such element is found. This is a resolving operation, will cause a full loop through all the elements of the iterable. * @param predicate The last element is to be returned which matches this asynchronous predicate. * @returns A promise of the last element matching the specified predicate, or `undefined` if no such element found. */ (predicate?: AsyncPredicate): Promise; /** * Returns the last element of the iterable matching an asynchronous predicate, or `undefined` value if no such element is found. This is a resolving operation, will cause a full loop through all the elements of the iterable. * @param predicate The last element is to be returned which matches this asynchronous predicate. * @returns A promise of the last element matching the specified predicate, or `undefined` if no such element found. */ (predicate: keyof T): Promise; }