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) 982 B
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('colour')) // => false nodehun .add('colour') .then(() => { console.log(nodehun.spellSync('colour')) // => 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('colour')) // => false await nodehun.add('colour') console.log(nodehun.spellSync('colour')) // => true, no longer incorrect } generate() /** * Sync */ nodehun = new Nodehun(dictionaries.en_US.affix, dictionaries.en_US.dictionary) console.log(nodehun.spellSync('colour')) // => false nodehun.addSync('colour') console.log(nodehun.spellSync('colour')) // => true, no longer incorrect