@arc-publishing/sdk-identity
Version:
JS Identity SDK for working with Identity API
20 lines • 859 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ONGOING_FETCHES = void 0;
var constants_1 = require("../sdk/constants");
exports.ONGOING_FETCHES = new Map();
function SingletonFetch(url, options, methodName) {
if (options === void 0) { options = {}; }
if (exports.ONGOING_FETCHES.has(methodName)) {
console.info("".concat(constants_1.logPrefix, " ").concat(methodName, " cannot be called until the previous to ").concat(methodName, " completes"));
return exports.ONGOING_FETCHES.get(methodName);
}
var fetchPromise = fetch(url, options)
.finally(function () {
exports.ONGOING_FETCHES.delete(methodName);
});
exports.ONGOING_FETCHES.set(methodName, fetchPromise);
return fetchPromise;
}
exports.default = SingletonFetch;
//# sourceMappingURL=SingletonFetch.js.map