FallbackModuleFactory.js 944 B

123456789101112131415161718192021222324252627
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr
  4. */
  5. "use strict";
  6. const ModuleFactory = require("../ModuleFactory");
  7. const FallbackModule = require("./FallbackModule");
  8. /** @typedef {import("../ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
  9. /** @typedef {import("../ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
  10. /** @typedef {import("./FallbackDependency")} FallbackDependency */
  11. module.exports = class FallbackModuleFactory extends ModuleFactory {
  12. /**
  13. * @param {ModuleFactoryCreateData} data data object
  14. * @param {function(Error=, ModuleFactoryResult=): void} callback callback
  15. * @returns {void}
  16. */
  17. create({ dependencies: [dependency] }, callback) {
  18. const dep = /** @type {FallbackDependency} */ (dependency);
  19. callback(null, {
  20. module: new FallbackModule(dep.requests)
  21. });
  22. }
  23. };