UNPKG

@arc-publishing/sdk-identity

Version:
16 lines 687 B
import { logPrefix } from '../sdk/constants'; export var ONGOING_FETCHES = new Map(); export default function SingletonFetch(url, options, methodName) { if (options === void 0) { options = {}; } if (ONGOING_FETCHES.has(methodName)) { console.info("".concat(logPrefix, " ").concat(methodName, " cannot be called until the previous to ").concat(methodName, " completes")); return ONGOING_FETCHES.get(methodName); } var fetchPromise = fetch(url, options) .finally(function () { ONGOING_FETCHES.delete(methodName); }); ONGOING_FETCHES.set(methodName, fetchPromise); return fetchPromise; } //# sourceMappingURL=SingletonFetch.js.map