Socket
Socket
Sign inDemoInstall

cspell-dictionary

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cspell-dictionary - npm Package Compare versions

Comparing version 6.25.0 to 6.26.0

dist/util/AutoResolve.d.ts

20

dist/SpellingDictionary/createInlineSpellingDictionary.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createInlineSpellingDictionary = void 0;
const AutoResolve_1 = require("../util/AutoResolve");
const util_1 = require("../util/util");

@@ -10,13 +11,16 @@ const createSpellingDictionary_1 = require("./createSpellingDictionary");

const SuggestDictionary_1 = require("./SuggestDictionary");
const cache = (0, AutoResolve_1.createAutoResolveWeakCache)();
function createInlineSpellingDictionary(inlineDict, source) {
const { words, flagWords, ignoreWords, suggestWords, name } = inlineDict;
const dictSources = [
words && (0, createSpellingDictionary_1.createSpellingDictionary)(words, name + '-words', source, inlineDict),
flagWords && (0, FlagWordsDictionary_1.createFlagWordsDictionary)(flagWords, name + '-flag-words', source),
ignoreWords && (0, IgnoreWordsDictionary_1.createIgnoreWordsDictionary)(ignoreWords, name + '-ignore-words', source),
suggestWords && (0, SuggestDictionary_1.createSuggestDictionary)(suggestWords, name + '-suggest', source),
].filter(util_1.isDefined);
return (0, SpellingDictionaryCollection_1.createCollection)(dictSources, name);
return cache.get(inlineDict, () => {
const { words, flagWords, ignoreWords, suggestWords, name } = inlineDict;
const dictSources = [
words && (0, createSpellingDictionary_1.createSpellingDictionary)(words, name + '-words', source, inlineDict),
flagWords && (0, FlagWordsDictionary_1.createFlagWordsDictionary)(flagWords, name + '-flag-words', source),
ignoreWords && (0, IgnoreWordsDictionary_1.createIgnoreWordsDictionary)(ignoreWords, name + '-ignore-words', source),
suggestWords && (0, SuggestDictionary_1.createSuggestDictionary)(suggestWords, name + '-suggest', source),
].filter(util_1.isDefined);
return (0, SpellingDictionaryCollection_1.createCollection)(dictSources, name);
});
}
exports.createInlineSpellingDictionary = createInlineSpellingDictionary;
//# sourceMappingURL=createInlineSpellingDictionary.js.map

18

dist/SpellingDictionary/FlagWordsDictionary.js

@@ -29,2 +29,3 @@ "use strict";

const cspell_trie_lib_1 = require("cspell-trie-lib");
const AutoResolve_1 = require("../util/AutoResolve");
const Defaults = __importStar(require("./defaults"));

@@ -123,2 +124,3 @@ const SpellingDictionary_1 = require("./SpellingDictionary");

}
const createCache = (0, AutoResolve_1.createAutoResolveWeakCache)();
/**

@@ -133,9 +135,11 @@ * Create a dictionary where all words are to be forbidden.

function createFlagWordsDictionary(wordList, name, source) {
const testSpecialCharacters = /[~*+]/;
const { t: specialWords, f: typoWords } = bisect((0, cspell_trie_lib_1.parseDictionaryLines)(wordList, { stripCaseAndAccents: false }), (line) => testSpecialCharacters.test(line));
const trieDict = specialWords.size ? buildTrieDict(specialWords, name, source) : undefined;
const typosDict = (0, TyposDictionary_1.createTyposDictionary)(typoWords, name, source);
if (!trieDict)
return typosDict;
return new FlagWordsDictionary(name, source, typosDict, trieDict);
return createCache.get(wordList, () => {
const testSpecialCharacters = /[~*+]/;
const { t: specialWords, f: typoWords } = bisect((0, cspell_trie_lib_1.parseDictionaryLines)(wordList, { stripCaseAndAccents: false }), (line) => testSpecialCharacters.test(line));
const trieDict = specialWords.size ? buildTrieDict(specialWords, name, source) : undefined;
const typosDict = (0, TyposDictionary_1.createTyposDictionary)(typoWords, name, source);
if (!trieDict)
return typosDict;
return new FlagWordsDictionary(name, source, typosDict, trieDict);
});
}

@@ -142,0 +146,0 @@ exports.createFlagWordsDictionary = createFlagWordsDictionary;

@@ -29,2 +29,3 @@ "use strict";

const cspell_trie_lib_1 = require("cspell-trie-lib");
const AutoResolve_1 = require("../util/AutoResolve");
const createSpellingDictionary_1 = require("./createSpellingDictionary");

@@ -98,2 +99,3 @@ const Defaults = __importStar(require("./defaults"));

}
const createCache = (0, AutoResolve_1.createAutoResolveWeakCache)();
/**

@@ -108,16 +110,18 @@ * Create a dictionary where all words are to be ignored.

function createIgnoreWordsDictionary(wordList, name, source) {
const testSpecialCharacters = /[*+]/;
const words = [...(0, cspell_trie_lib_1.parseDictionaryLines)(wordList, { stripCaseAndAccents: true })].map((w) => w.normalize(NormalizeForm));
const hasSpecial = words.findIndex((word) => testSpecialCharacters.test(word)) >= 0;
if (hasSpecial) {
return (0, createSpellingDictionary_1.createSpellingDictionary)(words, name, source, {
caseSensitive: true,
noSuggest: true,
weightMap: undefined,
supportNonStrictSearches: true,
});
}
return new IgnoreWordsDictionary(name, source, words);
return createCache.get(wordList, () => {
const testSpecialCharacters = /[*+]/;
const words = [...(0, cspell_trie_lib_1.parseDictionaryLines)(wordList, { stripCaseAndAccents: true })].map((w) => w.normalize(NormalizeForm));
const hasSpecial = words.findIndex((word) => testSpecialCharacters.test(word)) >= 0;
if (hasSpecial) {
return (0, createSpellingDictionary_1.createSpellingDictionary)(words, name, source, {
caseSensitive: true,
noSuggest: true,
weightMap: undefined,
supportNonStrictSearches: true,
});
}
return new IgnoreWordsDictionary(name, source, words);
});
}
exports.createIgnoreWordsDictionary = createIgnoreWordsDictionary;
//# sourceMappingURL=IgnoreWordsDictionary.js.map

@@ -28,2 +28,3 @@ "use strict";

const sync_1 = require("@cspell/cspell-pipe/sync");
const AutoResolve_1 = require("../util/AutoResolve");
const textMappers_1 = require("../util/textMappers");

@@ -85,2 +86,3 @@ const defaults = __importStar(require("./defaults"));

const sug = this.typosDef[word];
const isPreferred = true;
if (!sug)

@@ -93,7 +95,7 @@ return [];

cost: 1,
isPreferred: true,
isPreferred,
},
];
}
return sug.map((word, index) => ({ word, cost: index + 1 }));
return sug.map((word, index) => ({ word, cost: index + 1, isPreferred }));
}

@@ -111,2 +113,3 @@ genSuggestions(collector) {

}
const createCache = (0, AutoResolve_1.createAutoResolveWeakCache)();
/**

@@ -120,6 +123,8 @@ * Create a dictionary where all words are to be forbidden.

function createSuggestDictionary(entries, name, source) {
const def = (0, Typos_1.processEntriesToTyposDef)(entries);
return new SuggestDictionaryImpl(name, source, def);
return createCache.get(entries, () => {
const def = (0, Typos_1.processEntriesToTyposDef)(entries);
return new SuggestDictionaryImpl(name, source, def);
});
}
exports.createSuggestDictionary = createSuggestDictionary;
//# sourceMappingURL=SuggestDictionary.js.map

@@ -28,2 +28,3 @@ "use strict";

const sync_1 = require("@cspell/cspell-pipe/sync");
const AutoResolve_1 = require("../util/AutoResolve");
const textMappers_1 = require("../util/textMappers");

@@ -117,2 +118,3 @@ const defaults = __importStar(require("./defaults"));

const sug = this.typosDef[word];
const isPreferred = true;
if (!sug)

@@ -125,7 +127,7 @@ return [];

cost: 1,
isPreferred: true,
isPreferred,
},
];
}
return sug.map((word, index) => ({ word, cost: index + 1 }));
return sug.map((word, index) => ({ word, cost: index + 1, isPreferred }));
}

@@ -143,2 +145,3 @@ genSuggestions(collector) {

}
const createCache = (0, AutoResolve_1.createAutoResolveWeakCache)();
/**

@@ -152,6 +155,8 @@ * Create a dictionary where all words are to be forbidden.

function createTyposDictionary(entries, name, source) {
const def = (0, Typos_1.processEntriesToTyposDef)(entries);
return new TyposDictionaryImpl(name, source, def);
return createCache.get(entries, () => {
const def = (0, Typos_1.processEntriesToTyposDef)(entries);
return new TyposDictionaryImpl(name, source, def);
});
}
exports.createTyposDictionary = createTyposDictionary;
//# sourceMappingURL=TyposDictionary.js.map
{
"name": "cspell-dictionary",
"version": "6.25.0",
"version": "6.26.0",
"description": "A spelling dictionary library useful for checking words and getting suggestions.",

@@ -46,9 +46,9 @@ "main": "dist/index.js",

"dependencies": {
"@cspell/cspell-pipe": "6.25.0",
"@cspell/cspell-types": "6.25.0",
"cspell-trie-lib": "6.25.0",
"@cspell/cspell-pipe": "6.26.0",
"@cspell/cspell-types": "6.26.0",
"cspell-trie-lib": "6.26.0",
"fast-equals": "^4.0.3",
"gensequence": "^4.0.3"
},
"gitHead": "fd7541605e07c43887191097d58ab58d87fac8fd"
"gitHead": "a72f603f4f1afbe237f938b1a23d7cbe2a07d86f"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc