UNPKG

nodehun

Version:

The Hunspell binding for nodejs that exposes as much of hunspell as possible and also adds new features. Hunspell is a first class spellcheck library used by Google, Apple, and Mozilla.

35 lines (30 loc) 1.05 kB
const Nodehun = require('bindings')('Nodehun') const dictionaries = require('./dictionaries') let nodehun /** * Async : using the promise */ nodehun = new Nodehun(dictionaries.en_US.affix, dictionaries.en_US.dictionary) console.log(nodehun.spellSync('colouring')) // => false nodehun .addWithAffix('colour', 'color') .then(() => { console.log(nodehun.spellSync('colouring')) // => true, no longer incorrect }) /** * Async : using async/await */ nodehun = new Nodehun(dictionaries.en_US.affix, dictionaries.en_US.dictionary) async function generate() { console.log(nodehun.spellSync('colouring')) // => false await nodehun.addWithAffix('colour', 'color') console.log(nodehun.spellSync('colouring')) // => true, no longer incorrect } generate() /** * Sync */ nodehun = new Nodehun(dictionaries.en_US.affix, dictionaries.en_US.dictionary) console.log(nodehun.spellSync('colouring')) // => false nodehun.addWithAffixSync('colour', 'color') console.log(nodehun.spellSync('colouring')) // => true, no longer incorrect