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.
31 lines (24 loc) • 639 B
JavaScript
const Nodehun = require('bindings')('Nodehun')
const dictionaries = require('./dictionaries')
const nodehun = new Nodehun(dictionaries.en_US.affix, dictionaries.en_US.dictionary)
/**
* Async : using the promise
*/
nodehun
.generate('telling', 'ran')
.then(generate => {
console.log(generate) // => ['told']
})
/**
* Async : using async/await
*/
async function generateExample() {
const generate = await nodehun.generate('telling', 'ran')
console.log(generate) // => ['told']
}
generateExample()
/**
* Sync
*/
const generate = nodehun.generateSync('told', 'run')
console.log(generate) // => ['tell']