Skip to main content
Module

x/reservator/mod.ts>Reservator

🦕 Reservator is used to reserve resources or events with unique keys, and wait for them to be resolved or rejected.
Latest
class Reservator
import { Reservator } from "https://deno.land/x/reservator@v1.0.1/mod.ts";

A class representing a Reservator which can reserve and resolve a value with a given key.

Constructors

new
Reservator()

Constructs a new Reservator instance.

Type Parameters

K

The type of the key.

V

The type of the value.

Properties

readonly
size: number

Returns the number of reservations.

Methods

clear(): void

Removes all reservations.

reject(key: K, reason?: unknown): void

Rejects the reservation with the given key with the given reason.

reserve(key: K): Promise<V>

Reserves a value with the given key.

resolve(key: K, value: V): void

Resolves the reservation with the given key to the given value.