UNPKG

@da440dil/js-locker

Version:
20 lines (19 loc) 534 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Lock = void 0; class Lock { constructor(locker, key, token) { this.locker = locker; this.key = key; this.token = token; } async lock(ttl) { const v = await this.locker.lock(this.key, this.token, ttl); return { ok: v < -2, ttl: v }; } async unlock() { const v = await this.locker.unlock(this.key, this.token); return v === 1; } } exports.Lock = Lock;