node-aspell

Node.js bindings for aspell

Usage no npm install needed!

<script type="module">
  import nodeAspell from 'https://cdn.skypack.dev/node-aspell';
</script>

README

aspell Node Module

Native bindings to aspell spell checking library for Node.js.

Installation

npm install node-aspell

Usage

const spellChecker = require('node-aspell');
console.log(spellChecker.isMisspelled("pncils"));
console.log(spellChecker.getCorrectionsForMisspelling("pncils"));

spellChecker.isMisspelled(word)

Check if a word is misspelled.

word - String word to check.

Returns true if the word is misspelled, false otherwise.

spellChecker.isMisspelledAsync(word, callback)

Check if a word is misspelled asynchronously.

word - String word to check.

callback - Function to call with result callback(err, misspelled)

spellChecker.getCorrectionsForMisspelling(word)

Get the corrections for a misspelled word.

word - String word to get corrections for.

Returns a non-null but possibly empty array of string corrections.

spellChecker.getCorrectionsForMisspellingAsync(word, callback)

Get the corrections for a misspelled word asynchronously.

word - String word to get corrections for.

callback - Function to call with result

new Spellchecker(options)

In addition to the above functions that are used on a default instance, a new instance of SpellChecker can be instantiated with the use of the new operator. The same methods are available with the instance but the language/dictionary can be changed independently from the default instance. See the aspell options documentation for a full list of options: http://aspell.net/man-html/The-Options.html

const checker = new SpellChecker.Spellchecker({ lang: "es", encoding: "utf-8" });
const checker = new SpellChecker.Spellchecker({
    'master': 'es.rws',
    'dict-dir': '/var/lib/aspell',
    'encoding': 'utf-8'
});
const checker = new SpellChecker.Spellchecker("en_US");

Alternatives

These packages spawn a separate aspell process and parse the output:

aspell

aspell-stream