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) • 610 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
.stem('telling')
.then(stems => {
console.log(stems) // => ['telling', 'tell']
})
/**
* Async : using async/await
*/
async function getStems() {
const stems = await nodehun.stem('telling')
console.log(stems) // => ['telling', 'tell']
}
getStems()
/**
* Sync
*/
const stems = nodehun.stemSync('telling')
console.log(stems) // => ['telling', 'tell']