cspell-lib 5.18.0 → 5.18.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,7 +22,7 @@ class SpellingDictionaryFromTrie {
22
22
  this.isDictionaryCaseSensitive = (_a = options.caseSensitive) !== null && _a !== void 0 ? _a : !trie.isLegacy;
23
23
  this.containsNoSuggestWords = options.noSuggest || false;
24
24
  this._size = size || 0;
25
- this.weightMap = options.weightMap;
25
+ this.weightMap = options.weightMap || (0, SpellingDictionaryMethods_1.createWeightMapFromDictionaryInformation)(options.dictionaryInformation);
26
26
  }
27
27
  get size() {
28
28
  if (!this._size) {
@@ -1,11 +1,10 @@
1
1
  import { DictionaryInformation } from '@cspell/cspell-types';
2
- import { CompoundWordsMethod, SuggestionCollector, SuggestionResult, WeightMap } from 'cspell-trie-lib';
2
+ import { CompoundWordsMethod, SuggestionResult, WeightMap } from 'cspell-trie-lib';
3
3
  import { HasOptions, SearchOptions, SpellingDictionary, SuggestOptions } from './SpellingDictionary';
4
- export { suggestionCollector } from 'cspell-trie-lib';
4
+ export { impersonateCollector, suggestionCollector } from 'cspell-trie-lib';
5
5
  export declare type FilterSuggestionsPredicate = (word: SuggestionResult) => boolean;
6
6
  export declare type SuggestArgs = Parameters<SpellingDictionary['suggest']> | Parameters<(word: string, numSuggestions?: number, compoundMethod?: CompoundWordsMethod, numChanges?: number, ignoreCase?: boolean) => SuggestionResult[]>;
7
7
  export declare const defaultNumSuggestions = 10;
8
- export declare function impersonateCollector(collector: SuggestionCollector, word: string): SuggestionCollector;
9
8
  export declare function wordSearchFormsArray(word: string, isDictionaryCaseSensitive: boolean, ignoreCase: boolean): string[];
10
9
  export declare function wordSearchForms(word: string, isDictionaryCaseSensitive: boolean, ignoreCase: boolean): Set<string>;
11
10
  export declare function wordSuggestFormsArray(word: string): string[];
@@ -18,7 +17,9 @@ declare function wordDictionaryForms(word: string, prefixNoCase: string): Iterab
18
17
  export declare function wordDictionaryFormsCollector(prefixNoCase: string): (word: string) => Iterable<string>;
19
18
  export declare function hasOptionToSearchOption(opt: HasOptions | undefined): SearchOptions;
20
19
  export declare function suggestArgsToSuggestOptions(args: SuggestArgs): SuggestOptions;
21
- export declare function createWFromDictionaryInformation(di: DictionaryInformation): WeightMap;
20
+ export declare function createWeightMapFromDictionaryInformation(di: undefined): undefined;
21
+ export declare function createWeightMapFromDictionaryInformation(di: DictionaryInformation): WeightMap;
22
+ export declare function createWeightMapFromDictionaryInformation(di: DictionaryInformation | undefined): WeightMap | undefined;
22
23
  export declare const __testMethods: {
23
24
  wordSearchForms: typeof wordSearchForms;
24
25
  wordSearchFormsArray: typeof wordSearchFormsArray;
@@ -1,18 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.__testMethods = exports.createWFromDictionaryInformation = exports.suggestArgsToSuggestOptions = exports.hasOptionToSearchOption = exports.wordDictionaryFormsCollector = exports.wordSuggestForms = exports.wordSuggestFormsArray = exports.wordSearchForms = exports.wordSearchFormsArray = exports.impersonateCollector = exports.defaultNumSuggestions = exports.suggestionCollector = void 0;
3
+ exports.__testMethods = exports.createWeightMapFromDictionaryInformation = exports.suggestArgsToSuggestOptions = exports.hasOptionToSearchOption = exports.wordDictionaryFormsCollector = exports.wordSuggestForms = exports.wordSuggestFormsArray = exports.wordSearchForms = exports.wordSearchFormsArray = exports.defaultNumSuggestions = exports.suggestionCollector = exports.impersonateCollector = void 0;
4
4
  const cspell_trie_lib_1 = require("cspell-trie-lib");
5
5
  const gensequence_1 = require("gensequence");
6
6
  const text_1 = require("../util/text");
7
7
  var cspell_trie_lib_2 = require("cspell-trie-lib");
8
+ Object.defineProperty(exports, "impersonateCollector", { enumerable: true, get: function () { return cspell_trie_lib_2.impersonateCollector; } });
8
9
  Object.defineProperty(exports, "suggestionCollector", { enumerable: true, get: function () { return cspell_trie_lib_2.suggestionCollector; } });
9
10
  exports.defaultNumSuggestions = 10;
10
- function impersonateCollector(collector, word) {
11
- const r = Object.create(collector);
12
- Object.defineProperty(r, 'word', { value: word, writable: false });
13
- return r;
14
- }
15
- exports.impersonateCollector = impersonateCollector;
16
11
  function wordSearchFormsArray(word, isDictionaryCaseSensitive, ignoreCase) {
17
12
  return [...wordSearchForms(word, isDictionaryCaseSensitive, ignoreCase)];
18
13
  }
@@ -105,10 +100,10 @@ function suggestArgsToSuggestOptions(args) {
105
100
  return suggestOptions;
106
101
  }
107
102
  exports.suggestArgsToSuggestOptions = suggestArgsToSuggestOptions;
108
- function createWFromDictionaryInformation(di) {
109
- return (0, cspell_trie_lib_1.mapDictionaryInformationToWeightMap)(di);
103
+ function createWeightMapFromDictionaryInformation(di) {
104
+ return di ? (0, cspell_trie_lib_1.mapDictionaryInformationToWeightMap)(di) : undefined;
110
105
  }
111
- exports.createWFromDictionaryInformation = createWFromDictionaryInformation;
106
+ exports.createWeightMapFromDictionaryInformation = createWeightMapFromDictionaryInformation;
112
107
  exports.__testMethods = {
113
108
  wordSearchForms,
114
109
  wordSearchFormsArray,
@@ -38,7 +38,7 @@ function _createSpellingDictionary(params) {
38
38
  const trie = (0, cspell_trie_lib_1.buildTrieFast)(words);
39
39
  const opts = { ...(options || defaultOptions) };
40
40
  if (opts.weightMap === undefined && opts.dictionaryInformation) {
41
- opts.weightMap = (0, SpellingDictionaryMethods_1.createWFromDictionaryInformation)(opts.dictionaryInformation);
41
+ opts.weightMap = (0, SpellingDictionaryMethods_1.createWeightMapFromDictionaryInformation)(opts.dictionaryInformation);
42
42
  }
43
43
  return new SpellingDictionaryFromTrie_1.SpellingDictionaryFromTrie(trie, name, opts, source);
44
44
  }
@@ -75,8 +75,8 @@ exports.suggestionsForWord = suggestionsForWord;
75
75
  function combine(suggestions) {
76
76
  const words = new Map();
77
77
  for (const sug of suggestions) {
78
- const { word, cost, dictName } = sug;
79
- const f = words.get(word) || { word, cost, dictionaries: [] };
78
+ const { word, cost, dictName, ...rest } = sug;
79
+ const f = words.get(word) || { word, cost, ...rest, dictionaries: [] };
80
80
  f.cost = Math.min(f.cost, cost);
81
81
  f.dictionaries.push(dictName);
82
82
  f.dictionaries.sort();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell-lib",
3
- "version": "5.18.0",
3
+ "version": "5.18.4",
4
4
  "description": "A library of useful functions used across various cspell tools.",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -48,15 +48,15 @@
48
48
  },
49
49
  "homepage": "https://github.com/streetsidesoftware/cspell#readme",
50
50
  "dependencies": {
51
- "@cspell/cspell-bundled-dicts": "^5.18.0",
52
- "@cspell/cspell-types": "^5.18.0",
51
+ "@cspell/cspell-bundled-dicts": "^5.18.4",
52
+ "@cspell/cspell-types": "^5.18.4",
53
53
  "clear-module": "^4.1.2",
54
- "comment-json": "^4.1.1",
54
+ "comment-json": "^4.2.2",
55
55
  "configstore": "^5.0.1",
56
56
  "cosmiconfig": "^7.0.1",
57
- "cspell-glob": "^5.18.0",
58
- "cspell-io": "^5.18.0",
59
- "cspell-trie-lib": "^5.18.0",
57
+ "cspell-glob": "^5.18.4",
58
+ "cspell-io": "^5.18.4",
59
+ "cspell-trie-lib": "^5.18.4",
60
60
  "fast-equals": "^2.0.4",
61
61
  "find-up": "^5.0.0",
62
62
  "fs-extra": "^10.0.0",
@@ -76,19 +76,19 @@
76
76
  "@cspell/dict-fa-ir": "^1.0.17",
77
77
  "@cspell/dict-fr-fr": "^2.0.1",
78
78
  "@cspell/dict-html": "^1.1.9",
79
- "@cspell/dict-nl-nl": "^2.1.1",
79
+ "@cspell/dict-nl-nl": "^2.2.2",
80
80
  "@cspell/dict-python": "^2.0.5",
81
81
  "@types/configstore": "^5.0.1",
82
82
  "@types/fs-extra": "^9.0.13",
83
83
  "@types/jest": "^27.4.0",
84
- "@types/node": "^17.0.13",
84
+ "@types/node": "^17.0.15",
85
85
  "cspell-dict-nl-nl": "^1.1.2",
86
- "jest": "^27.4.7",
86
+ "jest": "^27.5.0",
87
87
  "lorem-ipsum": "^2.0.4",
88
88
  "rimraf": "^3.0.2",
89
- "rollup": "^2.66.1",
89
+ "rollup": "^2.67.0",
90
90
  "rollup-plugin-dts": "^4.1.0",
91
91
  "ts-jest": "^27.1.3"
92
92
  },
93
- "gitHead": "ef4c46dfb6f2938724afb5332ea2fdf9b67d99e4"
93
+ "gitHead": "26769ba64ce9eff227492524e5210709bec36416"
94
94
  }