npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

spellchecker

v3.7.1

Published

Bindings to native spellchecker

Downloads

24,662

Readme

SpellChecker Node Module Build Status Build status

Native bindings to NSSpellChecker, Hunspell, or the Windows 8 Spell Check API, depending on your platform. Windows 7 and below as well as Linux will rely on Hunspell.

Installing

npm install spellchecker

Using

SpellChecker = require 'spellchecker'

SpellChecker.isMisspelled(word)

Check if a word is misspelled.

word - String word to check.

Returns true if the word is misspelled, false otherwise.

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.checkSpelling(corpus)

Identify misspelled words in a corpus of text.

corpus - String corpus of text to spellcheck.

Returns an Array containing {start, end} objects that describe an index range within the original String that contains a misspelled word.

SpellChecker.checkSpellingAsync(corpus)

Asynchronously identify misspelled words.

corpus - String corpus of text to spellcheck.

Returns a Promise that resolves with the Array described by checkSpelling().

SpellChecker.add(word)

Adds a word to the dictionary. When using Hunspell, this will not modify the .dic file; new words must be added each time the spellchecker is created. Use a custom dictionary file.

word - String word to add.

Returns nothing.

new Spellchecker()

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 dictionary and underlying API can be changed independently from the default instance.

const checker = new SpellChecker.Spellchecker()

SpellChecker.Spellchecker.setSpellcheckerType(type)

Overrides the library selection for checking. Without this, the checker will use Hunspell on Linux, the Spell Checking API for Windows, and NSSpellChecker on Macs.

If the environment variable SPELLCHECKER_PREFER_HUNSPELL is set to any value, the library will fallback to always using the Hunspell implementation.

This is the same behavior as calling setSpellcheckerType with the USE_SYSTEM_DEFAULTS constant:

checker = new SpellChecker.Spellchecker
checker.setSpellcheckerType SpellChecker.USE_SYSTEM_DEFAULTS

To always use the system API and not fallback to Hunspell regardless of the environment variable, use the ALWAYS_USE_SYSTEM constant:

checker = new SpellChecker.Spellchecker
checker.setSpellcheckerType SpellChecker.ALWAYS_USE_SYSTEM

Likewise, Hunspell can be forced with the ALWAYS_USE_HUNSPELL constant.

const checker = new SpellChecker.Spellchecker();
checker.setSpellcheckerType(SpellChecker.ALWAYS_USE_SYSTEM);

On Linux, Hunspell is always used regardless of the setting. This method must also be called before any spelling is done otherwise it will throw an error.

This returns nothing.