insomnia-plugin-valorant
Version:
Adds template tags to Insomnia with Valorant data
19 lines • 642 B
JavaScript
;
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