cspell-dictionary 9.2.0 → 9.2.2

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.
@@ -10,21 +10,23 @@ class CachedDict {
10
10
  options;
11
11
  name;
12
12
  id = ++dictionaryCounter;
13
+ has;
14
+ #has;
13
15
  constructor(dict, options) {
14
16
  this.dict = dict;
15
17
  this.options = options;
16
18
  this.name = dict.name;
17
- // console.log(`CachedDict for ${this.name}`);
18
- }
19
- #has = autoCache((word) => this.dict.has(word, this.options), DefaultAutoCacheSize);
20
- has = logRequests
21
- ? (word) => {
19
+ const has = autoCache((word) => this.dict.has(word, this.options), DefaultAutoCacheSize);
20
+ const hasAndLog = (word) => {
22
21
  const time = performance.now() - startTime;
23
- const value = this.#has(word);
22
+ const value = has(word);
24
23
  log.push({ time, method: 'has', word, value });
25
24
  return value;
26
- }
27
- : this.#has;
25
+ };
26
+ this.#has = has;
27
+ this.has = logRequests ? hasAndLog : has;
28
+ // console.log(`CachedDict for ${this.name}`);
29
+ }
28
30
  isNoSuggestWord = autoCache((word) => this.dict.isNoSuggestWord(word, this.options), DefaultAutoCacheSize);
29
31
  isForbidden = autoCache((word) => this.dict.isForbidden(word), DefaultAutoCacheSize);
30
32
  getPreferredSuggestions = autoCache((word) => this.dict.getPreferredSuggestions?.(word), DefaultAutoCacheSize);
@@ -1,4 +1,4 @@
1
- interface AutoCache<R> extends CacheStats {
1
+ export interface AutoCache<R> extends CacheStats {
2
2
  (word: string): R;
3
3
  }
4
4
  export interface CacheStats {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public",
5
5
  "provenance": true
6
6
  },
7
- "version": "9.2.0",
7
+ "version": "9.2.2",
8
8
  "description": "A spelling dictionary library useful for checking words and getting suggestions.",
9
9
  "type": "module",
10
10
  "sideEffects": false,
@@ -54,14 +54,14 @@
54
54
  "node": ">=20"
55
55
  },
56
56
  "dependencies": {
57
- "@cspell/cspell-pipe": "9.2.0",
58
- "@cspell/cspell-types": "9.2.0",
59
- "cspell-trie-lib": "9.2.0",
60
- "fast-equals": "^5.2.2"
57
+ "@cspell/cspell-pipe": "9.2.2",
58
+ "@cspell/cspell-types": "9.2.2",
59
+ "cspell-trie-lib": "9.2.2",
60
+ "fast-equals": "^5.3.2"
61
61
  },
62
62
  "devDependencies": {
63
63
  "gensequence": "^7.0.0",
64
64
  "lorem-ipsum": "^2.0.8"
65
65
  },
66
- "gitHead": "6004e6a19e11985bc61e6578846195be07365049"
66
+ "gitHead": "594a58399cb9dad07cbb1d9cef6f2adb87560dd7"
67
67
  }