JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 23
  • Score
    100M100P100Q41843F

An async hunspell binding for node.js

Package Exports

  • spellcheck

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (spellcheck) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Description

An async hunspell binding for node.js.

Requirements

Install

npm install spellcheck

Examples

  • Check a word:
  // this example uses the en_US hunspell files from SCOWL:
  //   http://wordlist.sourceforge.net/
  var SpellCheck = require('spellcheck'),
        base = __dirname + (process.platform === 'win32' ? '\\' : '/'),
        spell = new SpellCheck(base + 'en_US.aff', base + 'en_US.dic');

  spell.check('sain', function(err, correct, suggestions) {
      if (err) throw err;
      if (correct)
        console.log('Word is spelled correctly!');
      else
        console.log('Word not recognized. Suggestions: ' + suggestions);
  });

  // output:
  // Word not recognized. Suggestions: chain,sin,saint,satin,stain,slain,swain,rain,sail,lain,said,gain,main,spin,pain

API

Methods

  • (constructor)(<_String_>affixPath, <_Integer_>dictPath) - Creates and returns a new SpellCheck instance. affixPath is an absolute path that points to an affix (.aff) file. dictPath is an absolute path that points to a dictionary (.dic) file.

  • check(<_String_>word, <_Function_>callback) - (void) - Spell checks the given word. The callback receives three arguments: an <_Error_> object in case of error (null otherwise), a <_Boolean_> indicating if the word was spelled correctly, and if the word was not recognized, an <_Array_> of suggested words.