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IACpC,EAAe,KAAK,EAAc,KAAK,IACzC,CAIF,IAAK,IAAI,EAAI,EAAG,EAAI,EAAuB,OAAQ,IAAK,CACtD,IAAI,EAAgB,EAAuB,QACvC,EAAU,EAAc,OAAO,EAAG,GACtC,EAAc,OAAO,EAAI,EAAG,EAAG,EAAQ,IACvC,EAAe,KAAK,EAAc,KAAK,IACzC,CAEA,IAAI,EAAU,EAAe,QAAO,CAAC,EAAM,IAClC,EAAQ,SAAS,IAAS,EAAe,QAAQ,KAAU,IAGpE,OAAuB,IAAnB,EAAQ,OACH,sCAGF,CACT,CAlIA,QACG,QAAQ,QAAS,iBACjB,YAAY,4BAEf,QACG,QAAQ,2CACR,MAAM,KACN,YAAY,gEACZ,QAAO,CAAC,EAAM,KACb,MAAM,EAAU,GACb,aAAa,GACb,WACA,MAAM,MAEH,EAAgB,GACnB,aAAa,GACb,WACA,MAAM,MAKT,cAFmB,MAAM,WAAW,EAAe,GAEzB,EAAe,EAAO,IA8GpD,QAAQ,MAAM,QAAQ","file":"/npm/js-spell-checker@1.0.4/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/js-spell-checker@1.0.4/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","#!/usr/bin/env node\n'use strict'\n\nconst fs = require('fs')\nconst array = require('lodash/array')\nconst program = require('commander')\nconst chalk = require('chalk')\nconst log = console.log\n\nprogram\n  .version('1.0.4', '-v, --version')\n  .description('JavaScript Spell Checker')\n\nprogram\n  .command('check <dictionary-file> <file-to-check>')\n  .alias('c')\n  .description('Check a list of words against a dictionary for a misspelling')\n  .action((dict, checkWords) => {\n    const dictArr = fs\n      .readFileSync(dict)\n      .toString()\n      .split('\\n')\n\n    const checkWordsArr = fs\n      .readFileSync(checkWords)\n      .toString()\n      .split('\\n')\n\n    // array of strings of misspelled words\n    const misspelled = array.difference(checkWordsArr, dictArr)\n\n    outputResults(misspelled, checkWordsArr, dictArr)\n  })\n\n// log results\nfunction outputResults(diffArr, checkWordsArr, dictArr) {\n  // array of objects with context for misspelled words\n  const output = []\n\n  checkWordsArr.forEach((word, i) => {\n    diffArr.forEach(misspelledWord => {\n      if (word === misspelledWord) {\n        output.push({\n          word: word,\n          line: i + 1,\n          suggestedWords: suggestions(misspelledWord, dictArr)\n        })\n      }\n    })\n  })\n\n  output.forEach(obj => {\n    log(\n      chalk`\n      Oh no, you misspelled: {red ${obj.word}}\n      You can find it on line number: {red ${obj.line}}\n      Here are some suggestions on spelling: {green ${obj.suggestedWords}}\n      `\n    )\n  })\n}\n\nfunction suggestions(misspelledWord, dictArr) {\n  const alphabet = [\n    'a',\n    'b',\n    'c',\n    'd',\n    'e',\n    'f',\n    'g',\n    'h',\n    'i',\n    'j',\n    'k',\n    'l',\n    'm',\n    'n',\n    'o',\n    'p',\n    'q',\n    'r',\n    's',\n    't',\n    'u',\n    'v',\n    'w',\n    'x',\n    'y',\n    'z'\n  ]\n\n  // break up word into array of characters\n  let misspelledWordBrokenUp = misspelledWord.toLowerCase().split('')\n  const suggestedWords = []\n\n  // subsitute\n  for (let i = 0; i < misspelledWordBrokenUp.length; i++) {\n    for (let j = 0; j < alphabet.length; j++) {\n      let suggestedWord = misspelledWordBrokenUp.slice()\n      suggestedWord[i] = alphabet[j]\n      suggestedWords.push(suggestedWord.join(''))\n    }\n  }\n\n  // remove letter\n  for (let i = 0; i < misspelledWordBrokenUp.length; i++) {\n    let suggestedWord = misspelledWordBrokenUp.slice()\n    suggestedWord.splice(i, 1)\n    suggestedWords.push(suggestedWord.join(''))\n  }\n\n  // add letter\n  for (let i = 0; i <= misspelledWordBrokenUp.length; i++) {\n    for (let j = 0; j < alphabet.length; j++) {\n      let suggestedWord = misspelledWordBrokenUp.slice()\n      // insert letter at each positon in array\n      suggestedWord.splice(i, 0, alphabet[j])\n      suggestedWords.push(suggestedWord.join(''))\n    }\n  }\n\n  // switch letter\n  for (let i = 0; i < misspelledWordBrokenUp.length; i++) {\n    let suggestedWord = misspelledWordBrokenUp.slice()\n    let replace = suggestedWord.splice(i, 1)\n    suggestedWord.splice(i + 1, 0, replace[0])\n    suggestedWords.push(suggestedWord.join(''))\n  }\n\n  let results = suggestedWords.filter((word, index) => {\n    return dictArr.includes(word) && suggestedWords.indexOf(word) === index\n  })\n\n  if (results.length === 0) {\n    return 'sorry we could not find anything...'\n  }\n\n  return results\n}\n\nprogram.parse(process.argv)\n"]}