Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function decompose(code) {
let decomposition = [];
let codepoint = codepoints[code];
for (let c of codepoint.decomposition) {
let codes = decompose(c);
codes = codes.length > 0 ? codes : [c];
decomposition.push(...codes);
}
return decomposition;
}
fs.writeFileSync(__dirname + '/use.trie', trie.toBuffer());
let stateMachine = compile(fs.readFileSync(__dirname + '/use.machine', 'utf8'), symbols);
let json = Object.assign({
categories: Object.keys(symbols),
decompositions: decompositions
}, stateMachine);
fs.writeFileSync(__dirname + '/use.json', JSON.stringify(json));
}
let trie = new UnicodeTrieBuilder;
for (let i = 0; i < codepoints.length; i++) {
let codepoint = codepoints[i];
if (codepoint) {
let category = OVERRIDES[codepoint.code] || CATEGORY_MAP[codepoint.indicSyllabicCategory] || 'X';
let position = getPosition(codepoint, category);
trie.set(codepoint.code, (symbols[category] << 8) | position);
}
}
fs.writeFileSync(__dirname + '/indic.trie', trie.toBuffer());
let stateMachine = compile(fs.readFileSync(__dirname + '/indic.machine', 'utf8'), symbols);
fs.writeFileSync(__dirname + '/indic.json', JSON.stringify(stateMachine));