How to use the dfa/compile function in dfa

To help you get started, we’ve selected a few dfa examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github foliojs / fontkit / src / opentype / shapers / gen-use.js View on Github external
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));
github foliojs / fontkit / src / opentype / shapers / gen-indic.js View on Github external
}

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));

dfa

A state machine compiler

MIT
Latest version published 6 years ago

Package Health Score

67 / 100
Full package analysis

Popular dfa functions