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

spech

v0.2.1

Published

Check your text for grammar and spelling error using multiple providers

Downloads

232

Readme

spech

Build Status NPM version

Check your text for grammar and spelling mistakes using multiple providers

  • Multiple libraries/services for grammar and spelling checking
  • Multilingual document support
  • Zero config
  • Can work offline (only with Hunspell provider)

Screenshot

Usage

Files checking

npx spech README.md

File name can be omitted, by default it searches files by **/*.md mask. Default language is English, it can be changed with -l flag:

spech -l ru

spech -l ru-RU -l en-US - for multilingual documents

String and STDIN checking

You can check a string value using STDIN or --input argument

cat README.md | spech

spech --input 'Check the text'

Directives

disable

<!-- spech-disable -->
This text is ignored
<!-- spech-enable -->

dictionary

Add a phrase to a local document dictionary

<!-- spech-dictionary myword -->

languages

Add document-specific languages

<!-- spech-languages en es -->

Providers

To configure a provider pass -p flag:

spech -p hunspell -p yandex

Other options can be set in a config file.

Hunspell

Hunspell is the most popular open-source spell checker which supports a great variety of languages.

Read more.

GrammarBot

Free grammar checking API. With an API key, you can receive 250 requests/day (~7500/mo) at no cost. Without an API key, requests are limited to 100 per day per IP address (~3000/mo). The API supports only English (en-US and en-GB).

Read more.

Yandex Speller

Free and very fast spell checker API for en, ru and uk languages. It provides free 10k requests/day or 10m characters/day.

Read more.

Configuring

Configuration can be stored in:

  • spech.config.js
  • "spech" section of the package.json

spech.config.js

module.exports = {
  languages: ['en-us'],
  providers: [
    { name: 'hunspell' },
    { name: 'grammarBot', apiKey: 'YOUR_API_KEY' },
  ],
};

More details.

Dictionaries

It's possible to add words which are marked as a mistake into a dictionary file. Just create a file with .dic extension in your project root:

mydictionary.dic

# Simple word
browserify
# Regexp
/Component.tsx?/

More details.

API Usage

The most useful parts of the library are available through facade class SpellChecker.

Here is a simple example how it can be used:

const { Config, SpellChecker } = require('spech');

async function getMistakes() {
  const config = new Config({ ignoreCase: false });
  const checker = new SpellChecker(config);

  await checker.addDocumentsByMask(process.cwd(), 'docs/*.md');
  checker.addDictionaryPhrase('exceptionphrase');
  checker.addProviderByConfig({ name: 'hunspell' });

  const noMistakes = await checker.checkDocuments();
  if (noMistakes) {
    return [];
  }
  
  const corrections = checker.documents.map(doc => doc.corrections).flat();
  return corrections.map(correction => correction.fragment);
}