IgnoreErrorModuleFactory.js
1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Ivan Kopeykin @vankop
*/
"use strict";
const ModuleFactory = require("./ModuleFactory");
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
/** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
/** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
/**
* Ignores error when module is unresolved
*/
class IgnoreErrorModuleFactory extends ModuleFactory {
/**
* @param {NormalModuleFactory} normalModuleFactory normalModuleFactory instance
*/
constructor(normalModuleFactory) {
super();
this.normalModuleFactory = normalModuleFactory;
}
/**
* @param {ModuleFactoryCreateData} data data object
* @param {function(Error=, ModuleFactoryResult=): void} callback callback
* @returns {void}
*/
create(data, callback) {
this.normalModuleFactory.create(data, (err, result) => {
return callback(null, result);
});
}
}
module.exports = IgnoreErrorModuleFactory;