API

Class AsyncLoop

An implementation of a loop for asynchronous functions.

Index
  • Constructor.

    Parameters

    • iterations: number

      the number of iterations.

    • func: (asyncLoop: AsyncLoop) => void

      the function to run each iteration

    • successCallback: () => void

      the callback that will be called upon successful execution

    • offset: number = 0

      starting offset.

    Returns AsyncLoop

index: number

Defines the current index of the loop.

iterations: number

Defines the number of iterations for the loop

  • Create and run an async loop.

    Parameters

    • iterations: number

      the number of iterations.

    • fn: (asyncLoop: AsyncLoop) => void

      the function to run each iteration

    • successCallback: () => void

      the callback that will be called upon successful execution

    • offset: number = 0

      starting offset.

    Returns AsyncLoop

    the created async loop object

  • A for-loop that will run a given number of iterations synchronous and the rest async.

    Parameters

    • iterations: number

      total number of iterations

    • syncedIterations: number

      number of synchronous iterations in each async iteration.

    • fn: (iteration: number) => void

      the function to call each iteration.

    • callback: () => void

      a success call back that will be called when iterating stops.

    • OptionalbreakFunction: () => boolean

      a break condition (optional)

    • timeout: number = 0

      timeout settings for the setTimeout function. default - 0.

    Returns AsyncLoop

    the created async loop object