UNPKG

fnbr

Version:

A library to interact with Epic Games' Fortnite HTTP and XMPP services

44 lines 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Represents an asynchronous task lock used for pending token refreshing or party changes * @private */ class AsyncLock { constructor() { this.lockPromise = undefined; } /** * Whether this lock is active */ get isLocked() { return !!this.lockPromise; } /** * Returns a promise that will resolve once the lock is released */ wait() { var _a; return ((_a = this.lockPromise) === null || _a === void 0 ? void 0 : _a.promise) || Promise.resolve(); } /** * Activates this lock */ lock() { let resolve; const promise = new Promise((res) => { resolve = res; }); this.lockPromise = { promise, resolve: resolve }; } /** * Deactivates this lock */ unlock() { var _a; (_a = this.lockPromise) === null || _a === void 0 ? void 0 : _a.resolve(); this.lockPromise = undefined; } } exports.default = AsyncLock; //# sourceMappingURL=AsyncLock.js.map