Options
All
  • Public
  • Public/Protected
  • All
Menu

Module lock

Even though there is no thread safety to deal with thanks to the magic of Promises there is still a need for locks.

Index

Classes

Type aliases

Variables

Functions

Type aliases

WithLockCallback

WithLockCallback: function

Function type that can be provided to [[AsyncLock.withCallback]].

Type declaration

    • Parameters

      Returns PromiseLike<T> | T

Variables

Const DEFAULT_LOCK_KEY

DEFAULT_LOCK_KEY: unique symbol = Symbol("global lock")

Key used if no key provided.

Functions

lockMethod

  • lockMethod(keyGenerator?: undefined | function): (Anonymous function)
  • Decorator which runs the underlying method in AsyncLock.withLock.

    This inherently converts the method to an async method!

    Parameters

    • Optional keyGenerator: undefined | function

      function used to generate the key(s). Input is the same arguments as the underlying method takes and this is bound to the target. Returning an array will cause each item to be used as a key. If you don't want this behaviour, wrap the array in another array:

      return [["key 1"]];

      If undefined no keys are used.

    Returns (Anonymous function)

Generated using TypeDoc