UNPKG

@rr0/cms

Version:

RR0 Content Management System (CMS)

31 lines (30 loc) 853 B
import { SourceFactory } from "./SourceFactory.js"; /** * Create Source objects and register them. */ export class SourceRegistry extends SourceFactory { constructor(dataService, http, baseUrl, options, time) { super(dataService, http, baseUrl, options, time); this.registry = {}; } /** * Create a Source object from an anchor's URL. * * @param context * @param href The anchor's URL string. */ async createExternal(context, href) { let source = await this.get(href); if (!source) { source = await super.createExternal(context, href); await this.register(href, source); } return source; } async get(href) { return this.registry[href]; } async register(href, source) { this.registry[href] = source; } }