high level SemaphoreMap

5.18.0

Hierarchy (view full)

Constructors

  • SemaphoreMap, provision semaphore with giving key

    Parameters

    • maximumSemObjects: number = ...

      maximumSemObjects to avoid OOM, the default value is 1000000

    • defaultSemCount: number = 10

      default sem permit number, the default value is 10

    Returns SemaphoreMap

Methods

  • wrap a function with semaphore, the different parameter will use different semaphore instance

    simply, it could be used as a deeply 'limit' function, after wrapping, the function will be limited by parameter values (by specific semaphore total count)

    Type Parameters

    • P extends any[]
    • T

    Parameters

    • runner: AsyncFunction<P, T>
    • extractor: ((args: P) => any) = DEFAULT_EXTRACTOR
        • (args): any
        • Parameters

          • args: P

          Returns any

    Returns AsyncFunction<P, T>