mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-11-10 15:04:45 +00:00
18 lines
527 B
JavaScript
18 lines
527 B
JavaScript
|
"use strict";
|
||
|
module.exports = inquire;
|
||
|
|
||
|
/**
|
||
|
* Requires a module only if available.
|
||
|
* @memberof util
|
||
|
* @param {string} moduleName Module to require
|
||
|
* @returns {?Object} Required module if available and not empty, otherwise `null`
|
||
|
*/
|
||
|
function inquire(moduleName) {
|
||
|
try {
|
||
|
var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval
|
||
|
if (mod && (mod.length || Object.keys(mod).length))
|
||
|
return mod;
|
||
|
} catch (e) {} // eslint-disable-line no-empty
|
||
|
return null;
|
||
|
}
|