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

Function patchDictPaths

node/opencc.js:133–142  ·  view source on GitHub ↗

* Recursively resolve all dict "file" paths in a config object to absolute * paths under the given base directory. * @param {Object} dict - A dict node from the config JSON. * @param {string} baseDir - Directory to resolve relative paths against.

(dict, baseDir)

Source from the content-addressed store, hash-verified

131 * @param {string} baseDir - Directory to resolve relative paths against.
132 */
133function patchDictPaths(dict, baseDir) {
134 if (!dict) return;
135 if (dict.type === 'group' && Array.isArray(dict.dicts)) {
136 for (const d of dict.dicts) {
137 patchDictPaths(d, baseDir);
138 }
139 } else if (dict.file && !path.isAbsolute(dict.file)) {
140 dict.file = path.join(baseDir, dict.file);
141 }
142}
143
144function filterTofuRiskDicts(dict, includeTofuRiskDictionaries) {
145 if (!dict) return null;

Callers 2

patchConfigPathsFunction · 0.85
opencc.jsFile · 0.85

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected