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

Function requireOptionalPeer

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

Source from the content-addressed store, hash-verified

91};
92
93function requireOptionalPeer(packageName) {
94 const searchPaths = [
95 process.cwd(),
96 path.join(__dirname, '..'),
97 __dirname,
98 ];
99 for (const searchPath of searchPaths) {
100 try {
101 return require(require.resolve(packageName, { paths: [searchPath] }));
102 } catch (e) {
103 // Try the next search path.
104 }
105 }
106 return null;
107}
108
109// Detect optional opencc-jieba plugin package.
110// When installed, jieba-based configs (e.g. s2twp_jieba.json) become available.

Callers 1

opencc.jsFile · 0.85

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected