Options
All
  • Public
  • Public/Protected
  • All
Menu

@eturino/small-utils

Index

Functions

  • forEachInSequence<T>(list: T[], fn: (x: T) => Promise<unknown>): Promise<void>
  • Similar to a forEach, but waits for the Promise of the first element to resolve before starting to run the next one.

    Type parameters

    • T

    Parameters

    • list: T[]

      list of items to map

    • fn: (x: T) => Promise<unknown>

      async function to run on each item (any result is ignored)

        • (x: T): Promise<unknown>
        • Parameters

          • x: T

          Returns Promise<unknown>

    Returns Promise<void>

    a void promise

  • mapInSequence<T, R>(list: T[], fn: (x: T) => Promise<R>): Promise<R[]>
  • Same as forEachInSequence, but returns a list of results.

    Similar to a map but waits for the Promise of the first element to resolve before starting to run the next one.

    see

    forEachInSequence

    Type parameters

    • T

    • R

    Parameters

    • list: T[]

      list of items to map

    • fn: (x: T) => Promise<R>

      async function to run on each item, and whose returns are added to the result list

        • (x: T): Promise<R>
        • Parameters

          • x: T

          Returns Promise<R>

    Returns Promise<R[]>

    the result of each fn call, in the same order as the items in the list

Generated using TypeDoc