sequence type fixes and refactor
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import { AsyncSequence } from "./async/types.js";
|
||||
import { Sequence } from "./sync/types.js";
|
||||
|
||||
export type Predicate<T> = (obj: T) => boolean;
|
||||
export type FilterPredicate<TElement, TFiltered extends TElement> = (obj: TElement) => obj is TFiltered;
|
||||
export type Converter<TFrom, TTo> = (obj: TFrom) => TTo;
|
||||
@@ -9,10 +12,12 @@ export type Equater<T> = (first: T, second: T) => boolean;
|
||||
|
||||
export type MaybeAsyncIterable<T> = Iterable<T> | AsyncIterable<T>;
|
||||
export type MaybeAsyncIterator<T> = Iterator<T> | AsyncIterator<T>;
|
||||
|
||||
export type MaybeAsyncGenerator<T> = Generator<T> | AsyncGenerator<T>;
|
||||
export type AsyncFunction<TFunc extends (...args: any) => any> = TFunc extends (...args: infer P) => infer R ? (...args: P) => Promise<Awaited<R>> : never;
|
||||
export type MaybePromise<T> = T | Promise<T>;
|
||||
export type MaybePromiseLike<T> = T | PromiseLike<T>;
|
||||
export type MaybeAsyncFunction<TFunc extends (...args: any) => any> = TFunc extends (...args: infer P) => infer R ? (...args: P) => MaybePromise<R> : never;
|
||||
export type MaybeAsyncSequence<T> = Sequence<T> | AsyncSequence<T>;
|
||||
|
||||
export type AsyncPredicate<T> = AsyncFunction<Predicate<T>>;
|
||||
export type MaybeAsyncPredicate<T> = MaybeAsyncFunction<Predicate<T>>;
|
||||
|
||||
Reference in New Issue
Block a user