Function mapAsync

Non-blocking version of Array.prototype.map, it will pause the map loop every pauseEvery. Keep in mind that depending on your code workload the pause interval and duration may be exact or longer than specified. It's the same single thread JavaScript nature setTimeout have to follow.

  • Type Parameters

    • T
    • Y

    Parameters

    • context: readonly T[]

      original array

    • callback: ((item: T, key: number, array: readonly T[]) => Y)

      map function

        • (item, key, array): Y
        • Parameters

          • item: T
          • key: number
          • array: readonly T[]

          Returns Y

    • pauseEvery: number = DEFAULT_MAX_BLOCK_TIME

      pause after this many ms

    • pauseTime: number = DEFAULT_WAIT_TIME

      how long to wait on pause

    Returns Promise<Y[]>