MCPcopy Create free account
hub / github.com/BYVoid/OpenCC / requireOptionalPackage

Function requireOptionalPackage

node/opencc.js:33–42  ·  view source on GitHub ↗
(packageName)

Source from the content-addressed store, hash-verified

31const packageRoot = path.join(__dirname, '..');
32
33function requireOptionalPackage(packageName) {
34 try {
35 return require(packageName);
36 } catch (error) {
37 if (error && error.code === 'MODULE_NOT_FOUND') {
38 return null;
39 }
40 throw error;
41 }
42}
43
44function resolveBindingPath() {
45 // The addon is always named opencc.node and ships either as a local build

Callers 1

resolveBindingPathFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected