cspell-lib 6.13.2 → 6.14.0
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.
|
@@ -4,6 +4,7 @@ exports.DictionaryLoader = void 0;
|
|
|
4
4
|
const sync_1 = require("@cspell/cspell-pipe/sync");
|
|
5
5
|
const cspell_dictionary_1 = require("cspell-dictionary");
|
|
6
6
|
const errors_1 = require("../../util/errors");
|
|
7
|
+
const StrongWeakMap_1 = require("../../util/StrongWeakMap");
|
|
7
8
|
const SpellingDictionaryError_1 = require("../SpellingDictionaryError");
|
|
8
9
|
const MAX_AGE = 10000;
|
|
9
10
|
const loaders = {
|
|
@@ -28,8 +29,8 @@ var LoadingState;
|
|
|
28
29
|
class DictionaryLoader {
|
|
29
30
|
constructor(cspellIO) {
|
|
30
31
|
this.cspellIO = cspellIO;
|
|
31
|
-
this.dictionaryCache = new
|
|
32
|
-
this.dictionaryCacheByDef = new
|
|
32
|
+
this.dictionaryCache = new StrongWeakMap_1.StrongWeakMap();
|
|
33
|
+
this.dictionaryCacheByDef = new StrongWeakMap_1.StrongWeakMap();
|
|
33
34
|
this.reader = toReader(cspellIO);
|
|
34
35
|
this.readerSync = toReaderSync(cspellIO);
|
|
35
36
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export declare class StrongWeakMap<K, V extends {}> implements Map<K, V> {
|
|
2
|
+
private map;
|
|
3
|
+
constructor(init?: [K, V][]);
|
|
4
|
+
clear(): void;
|
|
5
|
+
/**
|
|
6
|
+
* @returns true if an element in the Map existed and has been removed, or false if the element does not exist.
|
|
7
|
+
*/
|
|
8
|
+
delete(key: K): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Executes a provided function once per each key/value pair in the Map, in insertion order.
|
|
11
|
+
*/
|
|
12
|
+
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
|
|
13
|
+
/**
|
|
14
|
+
* Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
|
|
15
|
+
* @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
|
|
16
|
+
*/
|
|
17
|
+
get(key: K): V | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Note: has will cause the value object to live longer.
|
|
20
|
+
* See: [WeakRef - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef#notes_on_weakrefs)
|
|
21
|
+
* @returns boolean indicating whether an element with the specified key exists or not.
|
|
22
|
+
*/
|
|
23
|
+
has(key: K): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
|
|
26
|
+
*/
|
|
27
|
+
set(key: K, value: V): this;
|
|
28
|
+
/**
|
|
29
|
+
* @returns the number of elements in the Map. Note: it is possible that some of the values have been dereferenced
|
|
30
|
+
*/
|
|
31
|
+
get size(): number;
|
|
32
|
+
/** Returns an iterable of entries in the map. */
|
|
33
|
+
[Symbol.iterator](): IterableIterator<[K, V]>;
|
|
34
|
+
/**
|
|
35
|
+
* Returns an iterable of key, value pairs for every entry in the map.
|
|
36
|
+
*/
|
|
37
|
+
entries(): IterableIterator<[K, V]>;
|
|
38
|
+
/**
|
|
39
|
+
* Returns an iterable of keys in the map
|
|
40
|
+
*
|
|
41
|
+
* Note: It is possible that the value associated with the key was released.
|
|
42
|
+
*/
|
|
43
|
+
keys(): IterableIterator<K>;
|
|
44
|
+
/**
|
|
45
|
+
* Returns an iterable of values in the map
|
|
46
|
+
*/
|
|
47
|
+
values(): IterableIterator<V>;
|
|
48
|
+
readonly [Symbol.toStringTag]: string;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=StrongWeakMap.d.ts.map
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.StrongWeakMap = void 0;
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
6
|
+
class StrongWeakMap {
|
|
7
|
+
constructor(init) {
|
|
8
|
+
this[_a] = 'StrongWeakMap';
|
|
9
|
+
this.map = new Map(init?.map(([k, v]) => [k, new WeakRef(v)]));
|
|
10
|
+
}
|
|
11
|
+
clear() {
|
|
12
|
+
this.map.clear();
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @returns true if an element in the Map existed and has been removed, or false if the element does not exist.
|
|
16
|
+
*/
|
|
17
|
+
delete(key) {
|
|
18
|
+
return this.map.delete(key);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Executes a provided function once per each key/value pair in the Map, in insertion order.
|
|
22
|
+
*/
|
|
23
|
+
forEach(callbackfn,
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
thisArg) {
|
|
26
|
+
if (thisArg) {
|
|
27
|
+
callbackfn = callbackfn.bind(thisArg);
|
|
28
|
+
}
|
|
29
|
+
for (const [key, value] of this) {
|
|
30
|
+
callbackfn(value, key, this);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
|
|
35
|
+
* @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
|
|
36
|
+
*/
|
|
37
|
+
get(key) {
|
|
38
|
+
const ref = this.map.get(key);
|
|
39
|
+
if (!ref)
|
|
40
|
+
return undefined;
|
|
41
|
+
const value = ref.deref();
|
|
42
|
+
if (!value) {
|
|
43
|
+
this.map.delete(key);
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Note: has will cause the value object to live longer.
|
|
50
|
+
* See: [WeakRef - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef#notes_on_weakrefs)
|
|
51
|
+
* @returns boolean indicating whether an element with the specified key exists or not.
|
|
52
|
+
*/
|
|
53
|
+
has(key) {
|
|
54
|
+
const value = this.get(key);
|
|
55
|
+
return !!value;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
|
|
59
|
+
*/
|
|
60
|
+
set(key, value) {
|
|
61
|
+
this.map.set(key, new WeakRef(value));
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @returns the number of elements in the Map. Note: it is possible that some of the values have been dereferenced
|
|
66
|
+
*/
|
|
67
|
+
get size() {
|
|
68
|
+
return this.map.size;
|
|
69
|
+
}
|
|
70
|
+
/** Returns an iterable of entries in the map. */
|
|
71
|
+
[Symbol.iterator]() {
|
|
72
|
+
return this.entries();
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Returns an iterable of key, value pairs for every entry in the map.
|
|
76
|
+
*/
|
|
77
|
+
*entries() {
|
|
78
|
+
for (const key of this.map.keys()) {
|
|
79
|
+
const value = this.get(key);
|
|
80
|
+
if (!value)
|
|
81
|
+
continue;
|
|
82
|
+
yield [key, value];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Returns an iterable of keys in the map
|
|
87
|
+
*
|
|
88
|
+
* Note: It is possible that the value associated with the key was released.
|
|
89
|
+
*/
|
|
90
|
+
keys() {
|
|
91
|
+
return this.map.keys();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Returns an iterable of values in the map
|
|
95
|
+
*/
|
|
96
|
+
*values() {
|
|
97
|
+
for (const [_, value] of this) {
|
|
98
|
+
yield value;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.StrongWeakMap = StrongWeakMap;
|
|
103
|
+
_a = Symbol.toStringTag;
|
|
104
|
+
//# sourceMappingURL=StrongWeakMap.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell-lib",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.14.0",
|
|
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,18 +48,18 @@
|
|
|
48
48
|
},
|
|
49
49
|
"homepage": "https://github.com/streetsidesoftware/cspell#readme",
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@cspell/cspell-bundled-dicts": "6.
|
|
52
|
-
"@cspell/cspell-pipe": "6.
|
|
53
|
-
"@cspell/cspell-types": "6.
|
|
51
|
+
"@cspell/cspell-bundled-dicts": "6.14.0",
|
|
52
|
+
"@cspell/cspell-pipe": "6.14.0",
|
|
53
|
+
"@cspell/cspell-types": "6.14.0",
|
|
54
54
|
"clear-module": "^4.1.2",
|
|
55
55
|
"comment-json": "^4.2.3",
|
|
56
56
|
"configstore": "^5.0.1",
|
|
57
57
|
"cosmiconfig": "^7.0.1",
|
|
58
|
-
"cspell-dictionary": "6.
|
|
59
|
-
"cspell-glob": "6.
|
|
60
|
-
"cspell-grammar": "6.
|
|
61
|
-
"cspell-io": "6.
|
|
62
|
-
"cspell-trie-lib": "6.
|
|
58
|
+
"cspell-dictionary": "6.14.0",
|
|
59
|
+
"cspell-glob": "6.14.0",
|
|
60
|
+
"cspell-grammar": "6.14.0",
|
|
61
|
+
"cspell-io": "6.14.0",
|
|
62
|
+
"cspell-trie-lib": "6.14.0",
|
|
63
63
|
"fast-equals": "^4.0.3",
|
|
64
64
|
"find-up": "^5.0.0",
|
|
65
65
|
"fs-extra": "^10.1.0",
|
|
@@ -71,11 +71,11 @@
|
|
|
71
71
|
"vscode-uri": "^3.0.6"
|
|
72
72
|
},
|
|
73
73
|
"engines": {
|
|
74
|
-
"node": ">=14"
|
|
74
|
+
"node": ">=14.6"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@cspell/dict-cpp": "^4.0.0",
|
|
78
|
-
"@cspell/dict-csharp": "^4.0.
|
|
78
|
+
"@cspell/dict-csharp": "^4.0.1",
|
|
79
79
|
"@cspell/dict-css": "^3.0.0",
|
|
80
80
|
"@cspell/dict-fa-ir": "^2.0.0",
|
|
81
81
|
"@cspell/dict-fr-fr": "^2.1.1",
|
|
@@ -84,15 +84,15 @@
|
|
|
84
84
|
"@cspell/dict-python": "^4.0.0",
|
|
85
85
|
"@types/configstore": "^5.0.1",
|
|
86
86
|
"@types/fs-extra": "^9.0.13",
|
|
87
|
-
"@types/jest": "^29.2.
|
|
88
|
-
"@types/node": "^18.11.
|
|
87
|
+
"@types/jest": "^29.2.1",
|
|
88
|
+
"@types/node": "^18.11.9",
|
|
89
89
|
"cspell-dict-nl-nl": "^1.1.2",
|
|
90
90
|
"jest": "^29.2.2",
|
|
91
91
|
"lorem-ipsum": "^2.0.8",
|
|
92
92
|
"rimraf": "^3.0.2",
|
|
93
|
-
"rollup": "^2.
|
|
93
|
+
"rollup": "^3.2.5",
|
|
94
94
|
"rollup-plugin-dts": "^5.0.0",
|
|
95
95
|
"ts-jest": "^29.0.3"
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "9f5274766ae9e1e4796a7c10b78db4d98f04ea42"
|
|
98
98
|
}
|