@giancosta86/omnicourse-core
Version:
Core model for OmniCourse
22 lines • 995 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.CachingRawTaxonomyFetcher = void 0;
const hashed_1 = require("@rimbu/hashed");
var CachingRawTaxonomyFetcher;
(function (CachingRawTaxonomyFetcher) {
function create(sourceFetcher) {
const taxonomiesById = hashed_1.HashMap.builder();
async function getById(taxonomyId) {
const cachedTaxonomy = taxonomiesById.get(taxonomyId);
if (cachedTaxonomy) {
return Promise.resolve(cachedTaxonomy);
}
const rawTaxonomyFromSourceFetcher = await sourceFetcher(taxonomyId);
taxonomiesById.set(taxonomyId, rawTaxonomyFromSourceFetcher);
return rawTaxonomyFromSourceFetcher;
}
return getById;
}
CachingRawTaxonomyFetcher.create = create;
})(CachingRawTaxonomyFetcher || (exports.CachingRawTaxonomyFetcher = CachingRawTaxonomyFetcher = {}));
//# sourceMappingURL=CachingRawTaxonomyFetcher.js.map
;