New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cspell-lib

Package Overview
Dependencies
Maintainers
1
Versions
367
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cspell-lib - npm Package Compare versions

Comparing version 4.0.13 to 4.0.14

2

dist/SpellingDictionary/Dictionaries.js

@@ -18,5 +18,5 @@ "use strict";

const settingsDictionary = SpellingDictionary_1.createSpellingDictionary(words.concat(userWords), 'user_words', 'From Settings', { caseSensitive });
return SpellingDictionaryCollection_1.createCollectionP([...spellDictionaries, settingsDictionary], 'dictionary collection', flagWords);
return SpellingDictionaryCollection_1.createCollectionP([...spellDictionaries, Promise.resolve(settingsDictionary)], 'dictionary collection', flagWords);
}
exports.getDictionary = getDictionary;
//# sourceMappingURL=Dictionaries.js.map

@@ -42,3 +42,3 @@ import { IterableLike } from '../util/IterableLike';

export declare const defaultNumSuggestions = 10;
export declare function createSpellingDictionary(wordList: string[] | IterableLike<string>, name: string, source: string, options?: SpellingDictionaryOptions): Promise<SpellingDictionary>;
export declare function createSpellingDictionary(wordList: string[] | IterableLike<string>, name: string, source: string, options?: SpellingDictionaryOptions): SpellingDictionary;
export declare class SpellingDictionaryFromTrie implements SpellingDictionary {

@@ -45,0 +45,0 @@ readonly trie: Trie;

@@ -18,12 +18,52 @@ "use strict";

exports.defaultNumSuggestions = 10;
async function createSpellingDictionary(wordList, name, source, options) {
const { caseSensitive = false } = options || {};
const words = gensequence_1.genSequence(wordList)
function createSpellingDictionary(wordList, name, source, options) {
// console.log(`createSpellingDictionary ${name} ${source}`);
const opts = options || {};
const { caseSensitive = false } = opts;
const words = new Set(gensequence_1.genSequence(wordList)
.filter(word => typeof word === 'string')
.map(word => word.trim())
.filter(w => !!w)
.concatMap(wordDictionaryFormsCollector(caseSensitive))
.toArray();
const trie = cspell_trie_lib_1.Trie.create(words);
return new SpellingDictionaryFromTrie(trie, name, options, source, words.length);
.concatMap(wordDictionaryFormsCollector(caseSensitive)));
const mapWord = repMap_1.createMapper(opts.repMap || []);
let trieDict;
function getTrie() {
if (trieDict) {
return trieDict;
}
// console.log(`Build Trie ${name}`);
return trieDict = new SpellingDictionaryFromTrie(cspell_trie_lib_1.Trie.create(words), name, options, source, words.size);
}
const isDictionaryCaseSensitive = opts.caseSensitive || false;
const dict = {
name,
source,
type: 'SpellingDictionaryFromSet',
mapWord,
size: words.size,
isDictionaryCaseSensitive,
options: opts,
has: (word, hasOptions) => {
if (words.has(word)) {
return true;
}
const searchOptions = hasOptionToSearchOption(hasOptions);
const mWord = mapWord(word);
const { ignoreCase = true } = searchOptions;
const forms = wordSearchForms(mWord, isDictionaryCaseSensitive, ignoreCase);
for (const w of forms) {
if (words.has(w)) {
return true;
}
}
const useCompounds = searchOptions.useCompounds === undefined ? opts.useCompounds : searchOptions.useCompounds;
if (isDictionaryCaseSensitive || useCompounds || searchOptions.ignoreCase === false) {
return getTrie().has(word, hasOptions);
}
return false;
},
suggest: (...args) => getTrie().suggest(...args),
genSuggestions: (collector, suggestOptions) => getTrie().genSuggestions(collector, suggestOptions),
};
return dict;
}

@@ -30,0 +70,0 @@ exports.createSpellingDictionary = createSpellingDictionary;

@@ -21,2 +21,2 @@ import { CompoundWordsMethod, SpellingDictionary, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, HasOptions, SearchOptions, SuggestOptions } from './SpellingDictionary';

export declare function isWordInAnyDictionary(dicts: SpellingDictionary[], word: string, options: SearchOptions): boolean;
export declare function createCollectionP(dicts: Promise<SpellingDictionary>[], name: string, wordsToFlag: string[]): Promise<SpellingDictionaryCollection>;
export declare function createCollectionP(dicts: (Promise<SpellingDictionary> | SpellingDictionary)[], name: string, wordsToFlag: string[]): Promise<SpellingDictionaryCollection>;
{
"name": "cspell-lib",
"version": "4.0.13",
"version": "4.0.14",
"description": "A library of useful functions used across various cspell tools.",

@@ -104,3 +104,3 @@ "main": "dist/index.js",

},
"gitHead": "85e6ca3af255ce75436bea6679a9099253ed3c82"
"gitHead": "281c90b6d747cf6e9a93d85448880dd9aa5565f5"
}
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