All files / src/web bitshifters-source.js

100% Statements 9/9
100% Branches 2/2
100% Functions 5/5
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16            2x 2x 2x 2x 2x 2x        
import { BitshiftersArchive } from "../bitshifters.js";
import { describeBitshiftersEntry } from "./media-catalogue.js";
 
/** Bitshifters' releases as a media source: their catalogue with the prod pages it names, and its fetcher. */
export class BitshiftersSource {
    constructor({ media }) {
        this.archive = new BitshiftersArchive();
        media.addSource("bitshifters", (path) => this.archive.fetch(path));
        media.addLister("bitshifters", async () => (await this.archive.catalogue()).map(describeBitshiftersEntry));
        media.addDescriber("bitshifters", async (path) => {
            const entry = (await this.archive.catalogue()).find((file) => file.path === path);
            return entry && describeBitshiftersEntry(entry);
        });
    }
}