# lock() function · @imqueue/rpc

Source: https://imqueue.org/api/rpc/latest/rpc.lock/
Published: 2026-08-04
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/rpc 3.5.3 — generated reference, not hand-written

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:**

```typescript
export declare function lock(enabledOrOptions?: boolean | LockOptions): any;
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| enabledOrOptions | boolean \| [LockOptions](https://imqueue.org/api/rpc/latest/rpc.lockoptions/) | _(Optional)_ whether locking is enabled, or the lock options |


**Returns:**

any

a dual-mode method decorator

