This is very confusing as seen in #12974 or #12906. My suggestion would be "legacy."
return page.getOperatorList().then(function (opList) {
          var svgGfx = new pdfjsLib.SVGGraphics(page.commonObjs, page.objs);
          svgGfx.embedFonts = true;
          return svgGfx.getSVG(opList, viewport).then(function (svg) {
            return writeSvgToFile(svg, getFilePathForPage(pageNum)).then(
              function () {
                console.log("Page: " + pageNum);
              },
              function (err) {
                console.log("Error: " + err);
              }
            );
          });
        });
      });
    };
    for (var i = 1; i <= numPages; i++) {
      lastPromise = lastPromise.then(loadPage.bind(null, i));
    }
    return lastPromise;
  })
  .then(
    function () {
      console.log("# End of Document");
    },
    function (err) {
      console.error("Error: " + err);
    }
  );