lock() function

Creates a @lock() method decorator. Concurrent calls to the decorated method that share the same arguments are coalesced: only the first call is executed, and all the others resolve with its result. Call similarity is determined by the method's argument values. The returned decorator is dual-mode: it works both as a standard (TC39) and as a legacy method decorator.

Signature:

export declare function lock(enabledOrOptions?: boolean | LockOptions): any;

Parameters

Parameter

Type

Description

enabledOrOptions

boolean | LockOptions

(Optional) whether locking is enabled, or the lock options

Returns:

any

a dual-mode method decorator

Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.