UNPKG

insomnia-plugin-valorant

Version:
19 lines 642 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.onlyOne = void 0; /** * Takes a function that returns a promise and ensures that only one instance of the function is running at a time. * @param func the function to wrap */ function onlyOne(func) { let currentPromise = undefined; return async (...args) => { if (currentPromise !== undefined) return currentPromise; currentPromise = func(...args); currentPromise.finally(() => currentPromise = undefined); return currentPromise; }; } exports.onlyOne = onlyOne; //# sourceMappingURL=only-one.js.map