Ejemplo n.º 1
0
  // Try to load the file from the map.  If not in the map, try to load
  // from the fallback loader.
  async load(url: ResolvedUrl): Promise<string> {
    const file = this.files.get(url);

    if (file == null) {
      if (this.fallbackLoader) {
        if (this.fallbackLoader.canLoad(url)) {
          return this.fallbackLoader.load(url);
        }
        throw new Error(
            `${url} not present in file map and fallback loader can not load.`);
      }
      throw new Error(`${url} not present in file map and no fallback loader.`);
    }

    return getFileContents(file);
  }
Ejemplo n.º 2
0
 // Return true if we can return load the given url.
 canLoad(url: ResolvedUrl): boolean {
   return !!(
       this.files.has(url) ||
       this.fallbackLoader && this.fallbackLoader.canLoad(url));
 }
 // Return true if we can return load the given url.
 canLoad(url: string): boolean {
   return this.files.has(url) ||
       this.fallbackLoader && this.fallbackLoader.canLoad(url);
 }