1
0
This commit is contained in:
Herve BECHER
2025-05-24 12:11:44 +02:00
parent e5e6bffe1e
commit 0fd0e3bada
24 changed files with 1702 additions and 688 deletions

View File

@@ -1,15 +1,10 @@
import { AsyncSequence } from "./async/types.js";
import { Sequence } from "./sync/types.js";
export type Predicate<T> = (obj: T) => boolean;
export type AnyPredicate<T> = (obj: T) => unknown;
export type FilterPredicate<TElement, TFiltered extends TElement> = (obj: TElement) => obj is TFiltered;
export type TypePredicate<TElement, TType extends TElement> = (obj: TElement) => obj is TType;
export type Converter<TFrom, TTo> = (obj: TFrom) => TTo;
export type BiConverter<TFromFirst, TFromSecond, TTo> = (first: TFromFirst, second: TFromSecond) => TTo;
export type Action<T> = (obj: T) => unknown;
export type Accumulator<TElement, TAccumulator> = (acc: TAccumulator, obj: TElement) => TAccumulator;
export type Comparer<T> = (first: T, second: T) => number;
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>;
@@ -18,12 +13,13 @@ export type AsyncFunction<TFunc extends (...args: any) => any> = TFunc extends (
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 AsyncAnyPredicate<T> = AsyncFunction<AnyPredicate<T>>;
export type AsyncTypePredicate<TElement, TType extends TElement> = AsyncFunction<TypePredicate<TElement, TType>>;
export type MaybeAsyncPredicate<T> = MaybeAsyncFunction<Predicate<T>>;
export type MaybeAsyncAnyPredicate<T> = MaybeAsyncFunction<AnyPredicate<T>>;
export type MaybeAsyncTypePredicate<TElement, TType extends TElement> = MaybeAsyncFunction<TypePredicate<TElement, TType>>;
export type AsyncConverter<TFrom, TTo> = AsyncFunction<Converter<TFrom, TTo>>;
export type MaybeAsyncConverter<TFrom, TTo> = MaybeAsyncFunction<Converter<TFrom, TTo>>;
export type AsyncBiConverter<TFromFirst, TFromSecond, TTo> = AsyncFunction<BiConverter<TFromFirst, TFromSecond, TTo>>;
@@ -32,7 +28,4 @@ export type AsyncAction<T> = AsyncFunction<Action<T>>;
export type MaybeAsyncAction<T> = MaybeAsyncFunction<Action<T>>;
export type AsyncAccumulator<TElement, TAccumulator> = AsyncFunction<Accumulator<TElement, TAccumulator>>;
export type MaybeAsyncAccumulator<T, U> = MaybeAsyncFunction<Accumulator<T, U>>;
export type AsyncComparer<T> = AsyncFunction<Comparer<T>>;
export type MaybeAsyncComparer<T> = MaybeAsyncFunction<Comparer<T>>;
export type AsyncEquater<T> = AsyncFunction<Equater<T>>;
export type MaybeAsyncEquater<T> = MaybeAsyncFunction<Equater<T>>;