How to use the spellchecker.checkSpellingAsync function in spellchecker

To help you get started, we’ve selected a few spellchecker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tbroadley / github-spellcheck-cli / lib / spellcheck.js View on Github external
exports.getMisspellings = (document, filePath) => SpellChecker.checkSpellingAsync(document)
  .then((indices) => {
    const filteredIndices = isMarkdown(filePath) ?
      filterIndicesAndWords(indices, document) :
      filterWords(indices, document);
    const misspellings = filteredIndices.map(({ start, end }) => document.substring(start, end));
    const allSuggestions = misspellings.map(SpellChecker.getCorrectionsForMisspelling);
    const misspellingObjects = _.zipWith(
      filteredIndices,
      misspellings,
      allSuggestions,
      (index, misspelling, suggestions) => ({
        index,
        misspelling,
        suggestions,
      })
    );