Skip to content

Instantly share code, notes, and snippets.

@dontcallmedom
Created September 10, 2021 08:09
Show Gist options
  • Select an option

  • Save dontcallmedom/4ce7183bd1ac9d6bf79ae11da12f1898 to your computer and use it in GitHub Desktop.

Select an option

Save dontcallmedom/4ce7183bd1ac9d6bf79ae11da12f1898 to your computer and use it in GitHub Desktop.

Revisions

  1. dontcallmedom created this gist Sep 10, 2021.
    22 changes: 22 additions & 0 deletions update-interface-data.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    const fs = require("fs").promises;

    // @@@ download latest tagged version of @webref/idl repo
    const webrefPath = "../../webref/ed/";
    (async function () {
    const interfaceData = {};
    const index = JSON.parse(await fs.readFile(webrefPath + "idlnames.json", "utf-8"));
    (await Promise.all(
    Object.entries(index)
    .sort(([k1, v1], [k2, v2]) => k1.localeCompare(k2))
    .map(async ([,{parsed: jsonIdlPath}]) => await fs.readFile(webrefPath + jsonIdlPath, "utf-8"))
    )).forEach(jsonData => {
    const jsonIdl = JSON.parse(jsonData);
    if (jsonIdl.type === "interface" || jsonIdl.type === "interface mixin") {
    interfaceData[jsonIdl.name] = {
    inh: jsonIdl.inheritance?.name || "",
    impl: jsonIdl.includes.map(i => i.name)
    };
    }
    });
    console.log(JSON.stringify(interfaceData, null, 2));
    })();