All files / src/web sth-source.js

100% Statements 8/8
100% Branches 0/0
100% Functions 4/4
100% Lines 5/5

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 17            2x 2x 2x 2x 2x            
import { StairwayToHell } from "../sth.js";
import { describeSthDisc, describeSthTape } from "./media-catalogue.js";
 
/** The Stairway to Hell mirror as a media source: its disc and tape catalogues, and their fetchers. */
export class SthSource {
    constructor({ media }) {
        this.discs = new StairwayToHell();
        this.tapes = new StairwayToHell({ tapes: true });
        media.addSource("sth", (name) => this.discs.fetch(name));
        media.addSource("tapeSth", (name) => this.tapes.fetch(name));
        media.addLister("sth", async () => [
            ...(await this.discs.catalogue()).map(describeSthDisc),
            ...(await this.tapes.catalogue()).map(describeSthTape),
        ]);
    }
}