Type Alias IAsyncCollection<TInput>

IAsyncCollection: AsyncIterable<TInput> & {
    after(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>,
    ): LazyPromise<null | TInput>;
    afterOr<TExtended = TInput>(
        defaultValue: AsyncLazyable<TExtended>,
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>,
    ): LazyPromise<TInput | TExtended>;
    afterOrFail(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>,
    ): LazyPromise<TInput>;
    append<TExtended = TInput>(
        iterable: AsyncIterableValue<TInput | TExtended>,
    ): IAsyncCollection<TInput | TExtended>;
    average(): LazyPromise<Extract<TInput, number>>;
    before(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>,
    ): LazyPromise<null | TInput>;
    beforeOr<TExtended = TInput>(
        defaultValue: AsyncLazyable<TExtended>,
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>,
    ): LazyPromise<TInput | TExtended>;
    beforeOrFail(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>,
    ): LazyPromise<TInput>;
    change<TFilterOutput, TMapOutput>(
        predicateFn: AsyncPredicate<
            TInput,
            IAsyncCollection<TInput>,
            TFilterOutput,
        >,
        mapFn: AsyncMap<TFilterOutput, IAsyncCollection<TInput>, TMapOutput>,
    ): IAsyncCollection<TInput | TFilterOutput | TMapOutput>;
    chunk(chunkSize: number): IAsyncCollection<IAsyncCollection<TInput>>;
    chunkWhile(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>,
    ): IAsyncCollection<IAsyncCollection<TInput>>;
    collapse(): IAsyncCollection<AsyncCollapse<TInput>>;
    count(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>,
    ): LazyPromise<number>;
    countBy<TOutput = TInput>(
        selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>,
    ): IAsyncCollection<[TOutput, number]>;
    crossJoin<TExtended>(
        iterable: AsyncIterableValue<TExtended>,
    ): IAsyncCollection<CrossJoinResult<TInput, TExtended>>;
    difference<TOutput = TInput>(
        iterable: AsyncIterableValue<TInput>,
        selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>,
    ): IAsyncCollection<TInput>;
    entries(): IAsyncCollection<[number, TInput]>;
    every<TOutput>(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>,
    ): LazyPromise<boolean>;
    filter<TOutput>(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>,
    ): IAsyncCollection<TOutput>;
    first<TOutput>(
        predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>,
    ): LazyPromise<null | TOutput>;
    firstOr<TOutput, TExtended = TInput>(
        defaultValue: AsyncLazyable<TExtended>,
        predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>,
    ): LazyPromise<TOutput | TExtended>;
    firstOrFail<TOutput>(
        predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>,
    ): LazyPromise<TOutput>;
    flatMap<TOutput>(
        mapFn: AsyncMap<
            TInput,
            IAsyncCollection<TInput>,
            Iterable<TOutput, any, any>,
        >,
    ): IAsyncCollection<TOutput>;
    forEach(
        callback: AsyncForEach<TInput, IAsyncCollection<TInput>>,
    ): LazyPromise<void>;
    get(index: number): LazyPromise<null | TInput>;
    getOrFail(index: number): LazyPromise<TInput>;
    groupBy<TOutput = TInput>(
        selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>,
    ): IAsyncCollection<[TOutput, IAsyncCollection<TInput>]>;
    insertAfter<TExtended = TInput>(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>,
        iterable: AsyncIterableValue<TInput | TExtended>,
    ): IAsyncCollection<TInput | TExtended>;
    insertBefore<TExtended = TInput>(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>,
        iterable: AsyncIterableValue<TInput | TExtended>,
    ): IAsyncCollection<TInput | TExtended>;
    isEmpty(): LazyPromise<boolean>;
    isNotEmpty(): LazyPromise<boolean>;
    join(separator?: string): LazyPromise<Extract<TInput, string>>;
    keys(): IAsyncCollection<number>;
    last<TOutput>(
        predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>,
    ): LazyPromise<null | TOutput>;
    lastOr<TOutput, TExtended = TInput>(
        defaultValue: AsyncLazyable<TExtended>,
        predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>,
    ): LazyPromise<TOutput | TExtended>;
    lastOrFail<TOutput>(
        predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>,
    ): LazyPromise<TOutput>;
    map<TOutput>(
        mapFn: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>,
    ): IAsyncCollection<TOutput>;
    max(): LazyPromise<Extract<TInput, number>>;
    median(): LazyPromise<Extract<TInput, number>>;
    min(): LazyPromise<Extract<TInput, number>>;
    nth(step: number): IAsyncCollection<TInput>;
    padEnd<TExtended = TInput>(
        maxLength: number,
        fillItems: AsyncIterableValue<TExtended>,
    ): IAsyncCollection<TInput | TExtended>;
    padStart<TExtended = TInput>(
        maxLength: number,
        fillItems: AsyncIterableValue<TExtended>,
    ): IAsyncCollection<TInput | TExtended>;
    page(page: number, pageSize: number): IAsyncCollection<TInput>;
    partition(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>,
    ): IAsyncCollection<IAsyncCollection<TInput>>;
    percentage(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>,
    ): LazyPromise<number>;
    pipe<TOutput = TInput>(
        callback: AsyncTransform<IAsyncCollection<TInput>, TOutput>,
    ): LazyPromise<TOutput>;
    prepend<TExtended = TInput>(
        iterable: AsyncIterableValue<TInput | TExtended>,
    ): IAsyncCollection<TInput | TExtended>;
    reduce(
        reduceFn: AsyncReduce<TInput, IAsyncCollection<TInput>, TInput>,
    ): LazyPromise<TInput>;
    reduce(
        reduceFn: AsyncReduce<TInput, IAsyncCollection<TInput>, TInput>,
        initialValue: TInput,
    ): LazyPromise<TInput>;
    reduce<TOutput>(
        reduceFn: AsyncReduce<TInput, IAsyncCollection<TInput>, TOutput>,
        initialValue: TOutput,
    ): LazyPromise<TOutput>;
    reject<TOutput>(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>,
    ): IAsyncCollection<Exclude<TInput, TOutput>>;
    repeat(amount: number): IAsyncCollection<TInput>;
    reverse(chunkSize?: number): IAsyncCollection<TInput>;
    searchFirst(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>,
    ): LazyPromise<number>;
    searchLast(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>,
    ): LazyPromise<number>;
    set(
        index: number,
        value: TInput | AsyncMap<TInput, IAsyncCollection<TInput>, TInput>,
    ): IAsyncCollection<TInput>;
    shuffle(mathRandom?: () => number): IAsyncCollection<TInput>;
    size(): LazyPromise<number>;
    skip(offset: number): IAsyncCollection<TInput>;
    skipUntil(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>,
    ): IAsyncCollection<TInput>;
    skipWhile(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>,
    ): IAsyncCollection<TInput>;
    slice(start?: number, end?: number): IAsyncCollection<TInput>;
    sliding(
        chunkSize: number,
        step?: number,
    ): IAsyncCollection<IAsyncCollection<TInput>>;
    sole<TOutput>(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>,
    ): LazyPromise<TOutput>;
    some<TOutput>(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>,
    ): LazyPromise<boolean>;
    sort(comparator?: Comparator<TInput>): IAsyncCollection<TInput>;
    split(chunkAmount: number): IAsyncCollection<IAsyncCollection<TInput>>;
    sum(): LazyPromise<Extract<TInput, number>>;
    take(limit: number): IAsyncCollection<TInput>;
    takeUntil(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>,
    ): IAsyncCollection<TInput>;
    takeWhile(
        predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>,
    ): IAsyncCollection<TInput>;
    tap(callback: Tap<IAsyncCollection<TInput>>): IAsyncCollection<TInput>;
    toArray(): LazyPromise<TInput[]>;
    toIterator(): AsyncIterator<TInput, void, any>;
    toMap(): LazyPromise<EnsureMap<TInput>>;
    toRecord(): LazyPromise<EnsureRecord<TInput>>;
    unique<TOutput = TInput>(
        selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>,
    ): IAsyncCollection<TInput>;
    values(): IAsyncCollection<TInput>;
    when<TExtended = TInput>(
        condition: boolean,
        callback: AsyncModifier<
            IAsyncCollection<TInput>,
            IAsyncCollection<TExtended>,
        >,
    ): IAsyncCollection<TInput | TExtended>;
    whenEmpty<TExtended = TInput>(
        callback: AsyncModifier<
            IAsyncCollection<TInput>,
            IAsyncCollection<TExtended>,
        >,
    ): IAsyncCollection<TInput | TExtended>;
    whenNot<TExtended = TInput>(
        condition: boolean,
        callback: AsyncModifier<
            IAsyncCollection<TInput>,
            IAsyncCollection<TExtended>,
        >,
    ): IAsyncCollection<TInput | TExtended>;
    whenNotEmpty<TExtended = TInput>(
        callback: AsyncModifier<
            IAsyncCollection<TInput>,
            IAsyncCollection<TExtended>,
        >,
    ): IAsyncCollection<TInput | TExtended>;
    zip<TExtended>(
        iterable: AsyncIterableValue<TExtended>,
    ): IAsyncCollection<[TInput, TExtended]>;
}

The IAsyncCollection contract offers a fluent and efficient approach to working with AsyncIterable objects. IAsyncCollection is immutable.

IMPORT_PATH: "@daiso-tech/core/collection/contracts"

Type Parameters

  • TInput = unknown

Type declaration