cspell-lib
A library of useful functions used across various cspell tools.
Last updated 5 years ago by jason-dent .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install cspell-lib 
SYNC missed versions from official npm registry.

CSpell Library

cspell-lib is the workhorse behind cspell. It does all the heavy lifting necessary to spell check files.

Support Future Development

GitHub Sponsors

Open Collective

Street Side Software

PayPal

Installation

npm i -S cspell-lib

Usage

Example - Check some text

Here is an example of using spellCheckDocument to spell check some text with a spelling issue.

import assert from 'node:assert';

import { spellCheckDocument } from 'cspell-lib';

// cspell:ignore wordz coztom clockz cuztom
const customWords = ['wordz', 'cuztom', 'clockz'];

async function checkSpelling(phrase: string) {
  const result = await spellCheckDocument(
    { uri: 'text.txt', text: phrase, languageId: 'plaintext', locale: 'en' },
    { generateSuggestions: true, noConfigSearch: true },
    { words: customWords, suggestionsTimeout: 2000 }
  );
  return result.issues;
}

export async function run() {
  console.log(`Start: ${new Date().toISOString()}`);
  const r = await checkSpelling('These are my coztom wordz.');
  console.log(`End: ${new Date().toISOString()}`);
  // console.log(r);
  assert(r.length === 1, 'Make sure we got 1 spelling issue back.');
  assert(r[0].text === 'coztom');
  assert(r[0].suggestions?.includes('cuztom'));
  // console.log('%o', r);
}

Example - Check a file

import { resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import { spellCheckDocument } from 'cspell-lib';

export async function checkFile(filename: string) {
  const uri = pathToFileURL(resolve(filename)).toString();
  const result = await spellCheckDocument(
    { uri },
    { generateSuggestions: true, noConfigSearch: true },
    { words: customWords, suggestionsTimeout: 2000 }
  );
  return result.issues;
}

CSpell for Enterprise

Available as part of the Tidelift Subscription.

The maintainers of cspell and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. Learn more.



Brought to you byStreet Side Software Logo Street Side Software

Current Tags

  • 4.3.12                                ...           cspell4 (5 years ago)
  • 5.17.0                                ...           latest (4 years ago)
  • 5.17.0-alpha.0                                ...           next (4 years ago)

185 Versions

  • 5.17.0                                ...           4 years ago
  • 5.17.0-alpha.0                                ...           4 years ago
  • 5.16.0                                ...           4 years ago
  • 5.15.3                                ...           4 years ago
  • 5.15.2                                ...           4 years ago
  • 5.15.1                                ...           4 years ago
  • 5.15.0                                ...           4 years ago
  • 5.14.0                                ...           4 years ago
  • 5.14.0-alpha.0                                ...           4 years ago
  • 5.13.4                                ...           4 years ago
  • 5.13.3                                ...           4 years ago
  • 5.13.2                                ...           4 years ago
  • 5.13.1                                ...           4 years ago
  • 5.13.0                                ...           4 years ago
  • 5.12.6                                ...           4 years ago
  • 5.12.5                                ...           4 years ago
  • 5.12.4                                ...           4 years ago
  • 5.12.3                                ...           5 years ago
  • 5.12.2                                ...           5 years ago
  • 5.12.1                                ...           5 years ago
  • 5.12.0                                ...           5 years ago
  • 5.12.0-alpha.0                                ...           5 years ago
  • 5.11.1                                ...           5 years ago
  • 5.11.0                                ...           5 years ago
  • 5.11.0-alpha.0                                ...           5 years ago
  • 5.10.1                                ...           5 years ago
  • 5.10.0                                ...           5 years ago
  • 5.10.0-alpha.6                                ...           5 years ago
  • 5.10.0-alpha.5                                ...           5 years ago
  • 5.10.0-alpha.4                                ...           5 years ago
  • 5.10.0-alpha.3                                ...           5 years ago
  • 5.10.0-alpha.2                                ...           5 years ago
  • 5.9.1                                ...           5 years ago
  • 5.9.1-alpha.1                                ...           5 years ago
  • 5.9.0                                ...           5 years ago
  • 5.9.0-alpha.0                                ...           5 years ago
  • 5.8.2                                ...           5 years ago
  • 5.8.1                                ...           5 years ago
  • 5.8.0                                ...           5 years ago
  • 5.7.2                                ...           5 years ago
  • 5.7.1                                ...           5 years ago
  • 5.7.0                                ...           5 years ago
  • 5.7.0-alpha.0                                ...           5 years ago
  • 5.6.7                                ...           5 years ago
  • 5.6.6                                ...           5 years ago
  • 5.6.5                                ...           5 years ago
  • 5.6.4                                ...           5 years ago
  • 5.6.3                                ...           5 years ago
  • 5.6.2                                ...           5 years ago
  • 5.6.1                                ...           5 years ago
  • 5.6.0                                ...           5 years ago
  • 5.5.2                                ...           5 years ago
  • 5.5.1                                ...           5 years ago
  • 5.5.0                                ...           5 years ago
  • 5.4.1                                ...           5 years ago
  • 5.4.0                                ...           5 years ago
  • 5.3.12                                ...           5 years ago
  • 5.3.11                                ...           5 years ago
  • 5.3.10                                ...           5 years ago
  • 5.3.9                                ...           5 years ago
  • 5.3.8                                ...           5 years ago
  • 5.3.7                                ...           5 years ago
  • 5.3.7-alpha.3                                ...           5 years ago
  • 5.3.7-alpha.2                                ...           5 years ago
  • 5.3.7-alpha.0                                ...           5 years ago
  • 5.3.6                                ...           5 years ago
  • 5.3.5                                ...           5 years ago
  • 5.3.4                                ...           5 years ago
  • 5.3.3                                ...           5 years ago
  • 5.3.2                                ...           5 years ago
  • 5.3.1                                ...           5 years ago
  • 5.3.0                                ...           5 years ago
  • 5.3.0-alpha.4                                ...           5 years ago
  • 5.3.0-alpha.3                                ...           5 years ago
  • 5.3.0-alpha.2                                ...           5 years ago
  • 5.3.0-alpha.1                                ...           5 years ago
  • 5.3.0-alpha.0                                ...           5 years ago
  • 5.2.4                                ...           5 years ago
  • 5.2.3                                ...           5 years ago
  • 5.2.2                                ...           5 years ago
  • 5.2.1                                ...           5 years ago
  • 4.3.12                                ...           5 years ago
  • 5.2.0                                ...           5 years ago
  • 5.1.3                                ...           5 years ago
  • 5.1.2                                ...           5 years ago
  • 5.1.1                                ...           5 years ago
  • 4.3.11                                ...           5 years ago
  • 5.1.0                                ...           5 years ago
  • 5.0.8                                ...           5 years ago
  • 5.0.7                                ...           5 years ago
  • 5.0.6                                ...           5 years ago
  • 5.0.5                                ...           5 years ago
  • 4.3.10                                ...           5 years ago
  • 5.0.4                                ...           5 years ago
  • 5.0.3                                ...           5 years ago
  • 4.3.9                                ...           5 years ago
  • 4.3.8                                ...           5 years ago
  • 4.3.7                                ...           5 years ago
  • 5.0.2                                ...           5 years ago
  • 5.0.1                                ...           5 years ago
  • 5.0.1-alpha.15                                ...           5 years ago
  • 4.3.6                                ...           5 years ago
  • 5.0.1-alpha.13                                ...           5 years ago
  • 4.3.4                                ...           5 years ago
  • 5.0.1-alpha.12                                ...           5 years ago
  • 4.3.2                                ...           5 years ago
  • 4.3.1                                ...           5 years ago
  • 5.0.1-alpha.11                                ...           5 years ago
  • 5.0.1-alpha.10                                ...           5 years ago
  • 5.0.1-alpha.8                                ...           5 years ago
  • 4.3.0                                ...           5 years ago
  • 4.2.2                                ...           5 years ago
  • 5.0.1-alpha.7                                ...           5 years ago
  • 4.2.1                                ...           5 years ago
  • 5.0.1-alpha.6                                ...           5 years ago
  • 4.2.0                                ...           6 years ago
  • 5.0.1-alpha.5                                ...           6 years ago
  • 4.1.29                                ...           6 years ago
  • 4.1.28                                ...           6 years ago
  • 4.1.27                                ...           6 years ago
  • 4.1.26                                ...           6 years ago
  • 4.1.25                                ...           6 years ago
  • 4.1.24                                ...           6 years ago
  • 4.1.23                                ...           6 years ago
  • 5.0.1-alpha.4                                ...           6 years ago
  • 5.0.1-alpha.3                                ...           6 years ago
  • 4.1.22                                ...           6 years ago
  • 4.1.21                                ...           6 years ago
  • 4.1.20                                ...           6 years ago
  • 4.1.19                                ...           6 years ago
  • 4.1.18                                ...           6 years ago
  • 4.1.17                                ...           6 years ago
  • 4.1.16                                ...           6 years ago
  • 4.1.15                                ...           6 years ago
  • 4.1.14                                ...           6 years ago
  • 4.1.13                                ...           6 years ago
  • 4.1.12                                ...           6 years ago
  • 4.1.11                                ...           6 years ago
  • 4.1.10                                ...           6 years ago
  • 4.1.8                                ...           6 years ago
  • 4.1.7                                ...           6 years ago
  • 4.1.6                                ...           6 years ago
  • 4.1.5                                ...           6 years ago
  • 4.1.4                                ...           6 years ago
  • 4.1.3                                ...           6 years ago
  • 4.1.2                                ...           6 years ago
  • 4.1.1                                ...           6 years ago
  • 4.1.0                                ...           7 years ago
  • 4.0.26                                ...           7 years ago
  • 4.0.25                                ...           7 years ago
  • 4.0.24                                ...           7 years ago
  • 4.0.23                                ...           7 years ago
  • 4.0.22                                ...           7 years ago
  • 4.0.21                                ...           7 years ago
  • 4.0.20                                ...           7 years ago
  • 4.0.18                                ...           7 years ago
  • 4.0.17                                ...           7 years ago
  • 4.0.16                                ...           7 years ago
  • 4.0.15                                ...           7 years ago
  • 4.0.14                                ...           7 years ago
  • 4.0.13                                ...           7 years ago
  • 4.0.12                                ...           7 years ago
  • 4.0.11                                ...           7 years ago
  • 4.0.10                                ...           7 years ago
  • 4.0.9                                ...           7 years ago
  • 4.0.8                                ...           7 years ago
  • 4.0.6                                ...           7 years ago
  • 4.0.5                                ...           7 years ago
  • 4.0.4                                ...           7 years ago
  • 4.0.3                                ...           7 years ago
  • 3.0.8                                ...           7 years ago
  • 3.0.7                                ...           7 years ago
  • 3.0.6                                ...           7 years ago
  • 3.0.5                                ...           7 years ago
  • 3.0.4                                ...           8 years ago
  • 3.0.3                                ...           8 years ago
  • 3.0.2                                ...           8 years ago
  • 3.0.1                                ...           8 years ago
  • 3.0.0                                ...           8 years ago
  • 2.0.2                                ...           8 years ago
  • 2.0.1                                ...           8 years ago
  • 2.0.0                                ...           8 years ago
  • 1.0.2                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 22
Last Day 0
Last Week 82
Last Month 79
Dependencies (16)
Dev Dependencies (17)

Copyright 2013 - present © cnpmjs.org | Home |