cspell-trie-lib 7.3.9 → 8.1.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.
- package/dist/lib/ITrie.js +9 -1
- package/dist/lib/ITrieNode/walker/hintedWalker.js +6 -0
- package/dist/lib/TrieBlob/FastTrieBlob.js +16 -9
- package/dist/lib/TrieBlob/FastTrieBlobBuilder.js +16 -11
- package/dist/lib/TrieBlob/FastTrieBlobIRoot.js +9 -0
- package/dist/lib/TrieBlob/FastTrieBlobInternals.js +6 -0
- package/dist/lib/TrieBlob/TrieBlob.js +12 -5
- package/dist/lib/TrieBlob/TrieBlobIRoot.js +16 -0
- package/dist/lib/TrieBuilder.js +13 -11
- package/dist/lib/TrieNode/TrieNodeBuilder.js +2 -3
- package/dist/lib/TrieNode/TrieNodeTrie.js +4 -0
- package/dist/lib/TrieNode/trie-util.js +0 -1
- package/dist/lib/TrieNode/trie.js +5 -0
- package/dist/lib/convertToTrieRefNodes.js +0 -1
- package/dist/lib/distance/distanceAStarWeighted.js +4 -2
- package/dist/lib/distance/weightedMaps.js +1 -0
- package/dist/lib/models/locale/knownLocales.js +31 -31
- package/dist/lib/models/locale/locale.js +2 -0
- package/dist/lib/trie.js +8 -1
- package/dist/lib/utils/PairingHeap.js +3 -1
- package/dist/lib/utils/autoCacheMap.js +2 -0
- package/dist/lib/utils/secondChanceCache.js +3 -4
- package/package.json +7 -7
package/dist/lib/ITrie.js
CHANGED
|
@@ -10,10 +10,17 @@ import { mergeOptionalWithDefaults } from './utils/mergeOptionalWithDefaults.js'
|
|
|
10
10
|
import { replaceAllFactory } from './utils/util.js';
|
|
11
11
|
const defaultLegacyMinCompoundLength = 3;
|
|
12
12
|
export class ITrieImpl {
|
|
13
|
+
data;
|
|
14
|
+
numNodes;
|
|
15
|
+
_info;
|
|
16
|
+
_findOptionsDefaults;
|
|
17
|
+
hasForbidden;
|
|
18
|
+
root;
|
|
19
|
+
count;
|
|
20
|
+
weightMap;
|
|
13
21
|
constructor(data, numNodes) {
|
|
14
22
|
this.data = data;
|
|
15
23
|
this.numNodes = numNodes;
|
|
16
|
-
this.lastCreateFindOptionsMatchCaseMap = new Map();
|
|
17
24
|
this.root = data.getRoot();
|
|
18
25
|
this._info = mergeOptionalWithDefaults(data.info);
|
|
19
26
|
this.hasForbidden = data.hasForbiddenWords();
|
|
@@ -165,6 +172,7 @@ export class ITrieImpl {
|
|
|
165
172
|
});
|
|
166
173
|
return findOptions;
|
|
167
174
|
}
|
|
175
|
+
lastCreateFindOptionsMatchCaseMap = new Map();
|
|
168
176
|
createFindOptionsMatchCase(matchCase) {
|
|
169
177
|
const f = this.lastCreateFindOptionsMatchCaseMap.get(matchCase);
|
|
170
178
|
if (f !== undefined)
|
|
@@ -5,11 +5,18 @@ import { FastTrieBlobInternals } from './FastTrieBlobInternals.js';
|
|
|
5
5
|
import { FastTrieBlobIRoot } from './FastTrieBlobIRoot.js';
|
|
6
6
|
import { TrieBlob } from './TrieBlob.js';
|
|
7
7
|
export class FastTrieBlob {
|
|
8
|
+
nodes;
|
|
9
|
+
charIndex;
|
|
10
|
+
bitMasksInfo;
|
|
11
|
+
charToIndexMap;
|
|
12
|
+
_readonly = false;
|
|
13
|
+
_forbidIdx;
|
|
14
|
+
_iTrieRoot;
|
|
15
|
+
info;
|
|
8
16
|
constructor(nodes, charIndex, bitMasksInfo, options) {
|
|
9
17
|
this.nodes = nodes;
|
|
10
18
|
this.charIndex = charIndex;
|
|
11
19
|
this.bitMasksInfo = bitMasksInfo;
|
|
12
|
-
this._readonly = false;
|
|
13
20
|
this.info = mergeOptionalWithDefaults(options);
|
|
14
21
|
this.charToIndexMap = createCharToIndexMap(charIndex);
|
|
15
22
|
this._forbidIdx = this._lookupChar(0, this.info.forbiddenWordPrefix);
|
|
@@ -119,6 +126,14 @@ export class FastTrieBlob {
|
|
|
119
126
|
static toITrieNodeRoot(trie) {
|
|
120
127
|
return new FastTrieBlobIRoot(new FastTrieBlobInternals(trie.nodes, trie.charIndex, trie.charToIndexMap, trie.bitMasksInfo), 0, trie.info);
|
|
121
128
|
}
|
|
129
|
+
static NodeMaskEOW = TrieBlob.NodeMaskEOW;
|
|
130
|
+
static NodeChildRefShift = TrieBlob.NodeChildRefShift;
|
|
131
|
+
static NodeMaskChildCharIndex = TrieBlob.NodeMaskChildCharIndex;
|
|
132
|
+
static DefaultBitMaskInfo = {
|
|
133
|
+
NodeMaskEOW: FastTrieBlob.NodeMaskEOW,
|
|
134
|
+
NodeMaskChildCharIndex: FastTrieBlob.NodeMaskChildCharIndex,
|
|
135
|
+
NodeChildRefShift: FastTrieBlob.NodeChildRefShift,
|
|
136
|
+
};
|
|
122
137
|
get iTrieRoot() {
|
|
123
138
|
return (this._iTrieRoot ??= FastTrieBlob.toITrieNodeRoot(this));
|
|
124
139
|
}
|
|
@@ -154,14 +169,6 @@ export class FastTrieBlob {
|
|
|
154
169
|
return 0;
|
|
155
170
|
}
|
|
156
171
|
}
|
|
157
|
-
FastTrieBlob.NodeMaskEOW = TrieBlob.NodeMaskEOW;
|
|
158
|
-
FastTrieBlob.NodeChildRefShift = TrieBlob.NodeChildRefShift;
|
|
159
|
-
FastTrieBlob.NodeMaskChildCharIndex = TrieBlob.NodeMaskChildCharIndex;
|
|
160
|
-
FastTrieBlob.DefaultBitMaskInfo = {
|
|
161
|
-
NodeMaskEOW: FastTrieBlob.NodeMaskEOW,
|
|
162
|
-
NodeMaskChildCharIndex: FastTrieBlob.NodeMaskChildCharIndex,
|
|
163
|
-
NodeChildRefShift: FastTrieBlob.NodeChildRefShift,
|
|
164
|
-
};
|
|
165
172
|
function createCharToIndexMap(charIndex) {
|
|
166
173
|
const map = Object.create(null);
|
|
167
174
|
for (let i = 0; i < charIndex.length; ++i) {
|
|
@@ -5,10 +5,15 @@ import { FastTrieBlobInternals } from './FastTrieBlobInternals.js';
|
|
|
5
5
|
import { resolveMap } from './resolveMap.js';
|
|
6
6
|
import { TrieBlob } from './TrieBlob.js';
|
|
7
7
|
export class FastTrieBlobBuilder {
|
|
8
|
+
charToIndexMap = Object.create(null);
|
|
9
|
+
charIndex = [''];
|
|
10
|
+
nodes;
|
|
11
|
+
_readonly = false;
|
|
12
|
+
IdxEOW;
|
|
13
|
+
_cursor;
|
|
14
|
+
_options;
|
|
15
|
+
bitMasksInfo;
|
|
8
16
|
constructor(options, bitMasksInfo = FastTrieBlobBuilder.DefaultBitMaskInfo) {
|
|
9
|
-
this.charToIndexMap = Object.create(null);
|
|
10
|
-
this.charIndex = [''];
|
|
11
|
-
this._readonly = false;
|
|
12
17
|
this._options = mergeOptionalWithDefaults(options);
|
|
13
18
|
this.bitMasksInfo = bitMasksInfo;
|
|
14
19
|
this.nodes = [[0], Object.freeze([FastTrieBlobBuilder.NodeMaskEOW])];
|
|
@@ -260,13 +265,13 @@ export class FastTrieBlobBuilder {
|
|
|
260
265
|
walk(root);
|
|
261
266
|
return tf.build();
|
|
262
267
|
}
|
|
268
|
+
static NodeMaskEOW = TrieBlob.NodeMaskEOW;
|
|
269
|
+
static NodeChildRefShift = TrieBlob.NodeChildRefShift;
|
|
270
|
+
static NodeMaskChildCharIndex = TrieBlob.NodeMaskChildCharIndex;
|
|
271
|
+
static DefaultBitMaskInfo = {
|
|
272
|
+
NodeMaskEOW: FastTrieBlobBuilder.NodeMaskEOW,
|
|
273
|
+
NodeMaskChildCharIndex: FastTrieBlobBuilder.NodeMaskChildCharIndex,
|
|
274
|
+
NodeChildRefShift: FastTrieBlobBuilder.NodeChildRefShift,
|
|
275
|
+
};
|
|
263
276
|
}
|
|
264
|
-
FastTrieBlobBuilder.NodeMaskEOW = TrieBlob.NodeMaskEOW;
|
|
265
|
-
FastTrieBlobBuilder.NodeChildRefShift = TrieBlob.NodeChildRefShift;
|
|
266
|
-
FastTrieBlobBuilder.NodeMaskChildCharIndex = TrieBlob.NodeMaskChildCharIndex;
|
|
267
|
-
FastTrieBlobBuilder.DefaultBitMaskInfo = {
|
|
268
|
-
NodeMaskEOW: FastTrieBlobBuilder.NodeMaskEOW,
|
|
269
|
-
NodeMaskChildCharIndex: FastTrieBlobBuilder.NodeMaskChildCharIndex,
|
|
270
|
-
NodeChildRefShift: FastTrieBlobBuilder.NodeChildRefShift,
|
|
271
|
-
};
|
|
272
277
|
//# sourceMappingURL=FastTrieBlobBuilder.js.map
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
const EmptyKeys = Object.freeze([]);
|
|
2
2
|
const EmptyNodes = Object.freeze([]);
|
|
3
3
|
class FastTrieBlobINode {
|
|
4
|
+
trie;
|
|
5
|
+
nodeIdx;
|
|
6
|
+
id;
|
|
7
|
+
size;
|
|
8
|
+
node;
|
|
9
|
+
eow;
|
|
10
|
+
charToIdx;
|
|
11
|
+
_keys;
|
|
4
12
|
constructor(trie, nodeIdx) {
|
|
5
13
|
this.trie = trie;
|
|
6
14
|
this.nodeIdx = nodeIdx;
|
|
@@ -82,6 +90,7 @@ class FastTrieBlobINode {
|
|
|
82
90
|
}
|
|
83
91
|
}
|
|
84
92
|
export class FastTrieBlobIRoot extends FastTrieBlobINode {
|
|
93
|
+
info;
|
|
85
94
|
constructor(trie, nodeIdx, info) {
|
|
86
95
|
super(trie, nodeIdx);
|
|
87
96
|
this.info = info;
|
|
@@ -28,6 +28,13 @@ const headerSig = 'TrieBlob';
|
|
|
28
28
|
const version = '00.01.00';
|
|
29
29
|
const endianSig = 0x04030201;
|
|
30
30
|
export class TrieBlob {
|
|
31
|
+
nodes;
|
|
32
|
+
charIndex;
|
|
33
|
+
charToIndexMap;
|
|
34
|
+
info;
|
|
35
|
+
_forbidIdx;
|
|
36
|
+
_size;
|
|
37
|
+
_iTrieRoot;
|
|
31
38
|
constructor(nodes, charIndex, info) {
|
|
32
39
|
this.nodes = nodes;
|
|
33
40
|
this.charIndex = charIndex;
|
|
@@ -201,12 +208,12 @@ export class TrieBlob {
|
|
|
201
208
|
const nodes = new Uint32Array(blob.buffer).subarray(offsetNodes / 4, offsetNodes / 4 + lenNodes);
|
|
202
209
|
return new TrieBlob(nodes, charIndex, defaultTrieInfo);
|
|
203
210
|
}
|
|
211
|
+
static NodeMaskEOW = 0x00000100;
|
|
212
|
+
static NodeMaskNumChildren = (1 << NodeHeaderNumChildrenBits) - 1;
|
|
213
|
+
static NodeMaskNumChildrenShift = NodeHeaderNumChildrenShift;
|
|
214
|
+
static NodeChildRefShift = 8;
|
|
215
|
+
static NodeMaskChildCharIndex = 0x000000ff;
|
|
204
216
|
}
|
|
205
|
-
TrieBlob.NodeMaskEOW = 0x00000100;
|
|
206
|
-
TrieBlob.NodeMaskNumChildren = (1 << NodeHeaderNumChildrenBits) - 1;
|
|
207
|
-
TrieBlob.NodeMaskNumChildrenShift = NodeHeaderNumChildrenShift;
|
|
208
|
-
TrieBlob.NodeChildRefShift = 8;
|
|
209
|
-
TrieBlob.NodeMaskChildCharIndex = 0x000000ff;
|
|
210
217
|
function isLittleEndian() {
|
|
211
218
|
const buf = new Uint8Array([1, 2, 3, 4]);
|
|
212
219
|
const view = new DataView(buf.buffer);
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
export class TrieBlobInternals {
|
|
2
|
+
nodes;
|
|
3
|
+
charIndex;
|
|
4
|
+
charToIndexMap;
|
|
5
|
+
NodeMaskEOW;
|
|
6
|
+
NodeMaskNumChildren;
|
|
7
|
+
NodeMaskChildCharIndex;
|
|
8
|
+
NodeChildRefShift;
|
|
2
9
|
constructor(nodes, charIndex, charToIndexMap, maskInfo) {
|
|
3
10
|
this.nodes = nodes;
|
|
4
11
|
this.charIndex = charIndex;
|
|
@@ -13,6 +20,14 @@ export class TrieBlobInternals {
|
|
|
13
20
|
const EmptyKeys = Object.freeze([]);
|
|
14
21
|
const EmptyNodes = Object.freeze([]);
|
|
15
22
|
class TrieBlobINode {
|
|
23
|
+
trie;
|
|
24
|
+
nodeIdx;
|
|
25
|
+
id;
|
|
26
|
+
size;
|
|
27
|
+
node;
|
|
28
|
+
eow;
|
|
29
|
+
_keys;
|
|
30
|
+
charToIdx;
|
|
16
31
|
constructor(trie, nodeIdx) {
|
|
17
32
|
this.trie = trie;
|
|
18
33
|
this.nodeIdx = nodeIdx;
|
|
@@ -93,6 +108,7 @@ class TrieBlobINode {
|
|
|
93
108
|
}
|
|
94
109
|
}
|
|
95
110
|
export class TrieBlobIRoot extends TrieBlobINode {
|
|
111
|
+
info;
|
|
96
112
|
constructor(trie, nodeIdx, info) {
|
|
97
113
|
super(trie, nodeIdx);
|
|
98
114
|
this.info = info;
|
package/dist/lib/TrieBuilder.js
CHANGED
|
@@ -27,18 +27,20 @@ const MAX_NUM_SIGS = 100000;
|
|
|
27
27
|
const MAX_TRANSFORMS = 1000000;
|
|
28
28
|
const MAX_CACHE_SIZE = 1000000;
|
|
29
29
|
export class TrieBuilder {
|
|
30
|
+
count = 0;
|
|
31
|
+
signatures = new SecondChanceCache(MAX_NUM_SIGS);
|
|
32
|
+
cached = new SecondChanceCache(MAX_CACHE_SIZE);
|
|
33
|
+
transforms = new SecondChanceCache(MAX_TRANSFORMS);
|
|
34
|
+
_eow;
|
|
35
|
+
/** position 0 of lastPath is always the root */
|
|
36
|
+
lastPath = [{ s: '', n: { id: 0, f: undefined, c: undefined } }];
|
|
37
|
+
tails = new Map();
|
|
38
|
+
trieOptions;
|
|
39
|
+
numWords = 0;
|
|
40
|
+
_debug_lastWordsInserted = [];
|
|
41
|
+
// private _debug_mode = true;
|
|
42
|
+
_debug_mode = false;
|
|
30
43
|
constructor(words, trieOptions) {
|
|
31
|
-
this.count = 0;
|
|
32
|
-
this.signatures = new SecondChanceCache(MAX_NUM_SIGS);
|
|
33
|
-
this.cached = new SecondChanceCache(MAX_CACHE_SIZE);
|
|
34
|
-
this.transforms = new SecondChanceCache(MAX_TRANSFORMS);
|
|
35
|
-
/** position 0 of lastPath is always the root */
|
|
36
|
-
this.lastPath = [{ s: '', n: { id: 0, f: undefined, c: undefined } }];
|
|
37
|
-
this.tails = new Map();
|
|
38
|
-
this.numWords = 0;
|
|
39
|
-
this._debug_lastWordsInserted = [];
|
|
40
|
-
// private _debug_mode = true;
|
|
41
|
-
this._debug_mode = false;
|
|
42
44
|
this._eow = this.createNodeFrozen(1);
|
|
43
45
|
this.tails.set('', this._eow);
|
|
44
46
|
this._canBeCached(this._eow); // this line is just for coverage reasons
|
|
@@ -5,9 +5,8 @@ import { mergeOptionalWithDefaults } from '../utils/mergeOptionalWithDefaults.js
|
|
|
5
5
|
import { TrieNodeTrie } from './TrieNodeTrie.js';
|
|
6
6
|
const EOW = Object.freeze({ f: 1, k: true });
|
|
7
7
|
export class TrieNodeBuilder {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
8
|
+
_cursor;
|
|
9
|
+
root = { ...defaultTrieInfo, c: Object.create(null) };
|
|
11
10
|
setOptions(options) {
|
|
12
11
|
const opts = mergeOptionalWithDefaults(options, this.root);
|
|
13
12
|
Object.assign(this.root, opts);
|
|
@@ -5,6 +5,10 @@ import { findWordExact } from './find.js';
|
|
|
5
5
|
import { trieRootToITrieRoot } from './trie.js';
|
|
6
6
|
import { countNodes, createTrieRootFromList, iteratorTrieWords } from './trie-util.js';
|
|
7
7
|
export class TrieNodeTrie {
|
|
8
|
+
root;
|
|
9
|
+
_iTrieRoot;
|
|
10
|
+
info;
|
|
11
|
+
_size;
|
|
8
12
|
constructor(root) {
|
|
9
13
|
this.root = root;
|
|
10
14
|
this.info = mergeOptionalWithDefaults(root);
|
|
@@ -8,6 +8,9 @@ const EmptyKeys = Object.freeze([]);
|
|
|
8
8
|
const EmptyValues = Object.freeze([]);
|
|
9
9
|
const EmptyEntries = Object.freeze([]);
|
|
10
10
|
class ImplITrieNode {
|
|
11
|
+
node;
|
|
12
|
+
id;
|
|
13
|
+
_keys;
|
|
11
14
|
constructor(node) {
|
|
12
15
|
this.node = node;
|
|
13
16
|
this.id = node;
|
|
@@ -65,6 +68,8 @@ class ImplITrieNode {
|
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
70
|
class ImplITrieRoot extends ImplITrieNode {
|
|
71
|
+
root;
|
|
72
|
+
info;
|
|
68
73
|
constructor(root) {
|
|
69
74
|
super(root);
|
|
70
75
|
this.root = root;
|
|
@@ -98,11 +98,13 @@ function _distanceAStarWeightedEx(wordA, wordB, map, cost = 100) {
|
|
|
98
98
|
return best;
|
|
99
99
|
}
|
|
100
100
|
class CandidatePool {
|
|
101
|
+
aN;
|
|
102
|
+
bN;
|
|
103
|
+
pool = new PairingHeap(compare);
|
|
104
|
+
grid = [];
|
|
101
105
|
constructor(aN, bN) {
|
|
102
106
|
this.aN = aN;
|
|
103
107
|
this.bN = bN;
|
|
104
|
-
this.pool = new PairingHeap(compare);
|
|
105
|
-
this.grid = [];
|
|
106
108
|
}
|
|
107
109
|
next() {
|
|
108
110
|
let n;
|
|
@@ -80,7 +80,7 @@ export const codes = [
|
|
|
80
80
|
['de-IT', 'German', 'Italy'],
|
|
81
81
|
['de-LI', 'German', 'Liechtenstein'],
|
|
82
82
|
['de-LU', 'German', 'Luxembourg'],
|
|
83
|
-
['dz', 'Dzongkha'],
|
|
83
|
+
['dz', 'Dzongkha'], // cspell:ignore Dzongkha
|
|
84
84
|
['dz-BT', 'Dzongkha', 'Bhutan'],
|
|
85
85
|
['ee', 'Ewe'],
|
|
86
86
|
['ee-GH', 'Ewe', 'Ghana'],
|
|
@@ -115,7 +115,7 @@ export const codes = [
|
|
|
115
115
|
['en-ER', 'English', 'Eritrea'],
|
|
116
116
|
['en-FI', 'English', 'Finland'],
|
|
117
117
|
['en-FJ', 'English', 'Fiji'],
|
|
118
|
-
['en-FK', 'English', 'Falkland Islands (Islas Malvinas)'],
|
|
118
|
+
['en-FK', 'English', 'Falkland Islands (Islas Malvinas)'], // cspell:ignore Islas
|
|
119
119
|
['en-FM', 'English', 'Micronesia'],
|
|
120
120
|
['en-GB', 'English', 'United Kingdom'],
|
|
121
121
|
['en-GD', 'English', 'Grenada'],
|
|
@@ -135,7 +135,7 @@ export const codes = [
|
|
|
135
135
|
['en-JM', 'English', 'Jamaica'],
|
|
136
136
|
['en-KE', 'English', 'Kenya'],
|
|
137
137
|
['en-KI', 'English', 'Kiribati'],
|
|
138
|
-
['en-KN', 'English', 'Saint Kitts and Nevis'],
|
|
138
|
+
['en-KN', 'English', 'Saint Kitts and Nevis'], // cspell:ignore Kitts
|
|
139
139
|
['en-KY', 'English', 'Cayman Islands'],
|
|
140
140
|
['en-LC', 'English', 'Saint Lucia'],
|
|
141
141
|
['en-LR', 'English', 'Liberia'],
|
|
@@ -174,8 +174,8 @@ export const codes = [
|
|
|
174
174
|
['en-SS', 'English'],
|
|
175
175
|
['en-SX', 'English'],
|
|
176
176
|
['en-SZ', 'English', 'Swaziland'],
|
|
177
|
-
['en-TC', 'English', 'Turks and Caicos Islands'],
|
|
178
|
-
['en-TK', 'English', 'Tokelau'],
|
|
177
|
+
['en-TC', 'English', 'Turks and Caicos Islands'], // cspell:ignore Caicos
|
|
178
|
+
['en-TK', 'English', 'Tokelau'], // cspell:ignore Tokelau
|
|
179
179
|
['en-TO', 'English', 'Tonga'],
|
|
180
180
|
['en-TT', 'English', 'Trinidad and Tobago'],
|
|
181
181
|
['en-TV', 'English', 'Tuvalu'],
|
|
@@ -199,7 +199,7 @@ export const codes = [
|
|
|
199
199
|
['es-BZ', 'Spanish', 'Belize'],
|
|
200
200
|
['es-CL', 'Spanish', 'Chile'],
|
|
201
201
|
['es-CO', 'Spanish', 'Colombia'],
|
|
202
|
-
['es-CR', 'Spanish', 'Costa Rica'],
|
|
202
|
+
['es-CR', 'Spanish', 'Costa Rica'], // cspell:ignore Rica
|
|
203
203
|
['es-CU', 'Spanish', 'Cuba'],
|
|
204
204
|
['es-DO', 'Spanish', 'Dominican Republic'],
|
|
205
205
|
['es-EA', 'Spanish'],
|
|
@@ -227,19 +227,19 @@ export const codes = [
|
|
|
227
227
|
['fa', 'Persian'],
|
|
228
228
|
['fa-AF', 'Persian', 'Afghanistan'],
|
|
229
229
|
['fa-IR', 'Persian', 'Iran'],
|
|
230
|
-
['ff', 'Fulah'],
|
|
230
|
+
['ff', 'Fulah'], // cspell:ignore Fulah
|
|
231
231
|
['ff-CM', 'Fulah', 'Cameroon'],
|
|
232
232
|
['ff-GN', 'Fulah', 'Guinea'],
|
|
233
233
|
['ff-MR', 'Fulah', 'Mauritania'],
|
|
234
234
|
['ff-SN', 'Fulah', 'Senegal'],
|
|
235
235
|
['fi', 'Finnish'],
|
|
236
236
|
['fi-FI', 'Finnish', 'Finland'],
|
|
237
|
-
['fo', 'Faroese'],
|
|
237
|
+
['fo', 'Faroese'], // cspell:ignore Faroese
|
|
238
238
|
['fo-DK', 'Faroese', 'Denmark'],
|
|
239
239
|
['fo-FO', 'Faroese', 'Faroe Islands'],
|
|
240
240
|
['fr', 'French'],
|
|
241
241
|
['fr-BE', 'French', 'Belgium'],
|
|
242
|
-
['fr-BF', 'French', 'Burkina Faso'],
|
|
242
|
+
['fr-BF', 'French', 'Burkina Faso'], // cspell:ignore Burkina Faso
|
|
243
243
|
['fr-BI', 'French', 'Burundi'],
|
|
244
244
|
['fr-BJ', 'French', 'Benin'],
|
|
245
245
|
['fr-BL', 'French'],
|
|
@@ -248,7 +248,7 @@ export const codes = [
|
|
|
248
248
|
['fr-CF', 'French', 'Central African Republic'],
|
|
249
249
|
['fr-CG', 'French', 'Congo'],
|
|
250
250
|
['fr-CH', 'French', 'Switzerland'],
|
|
251
|
-
['fr-CI', "French, Cote d'Ivoire (Ivory Coast)"],
|
|
251
|
+
['fr-CI', "French, Cote d'Ivoire (Ivory Coast)"], // cspell:ignore d'Ivoire
|
|
252
252
|
['fr-CM', 'French', 'Cameroon'],
|
|
253
253
|
['fr-DJ', 'French', 'Djibouti'],
|
|
254
254
|
['fr-DZ', 'French', 'Algeria'],
|
|
@@ -256,7 +256,7 @@ export const codes = [
|
|
|
256
256
|
['fr-GA', 'French', 'Gabon'],
|
|
257
257
|
['fr-GF', 'French', 'French Guiana'],
|
|
258
258
|
['fr-GN', 'French', 'Guinea'],
|
|
259
|
-
['fr-GP', 'French', 'Saint Barthelemy'],
|
|
259
|
+
['fr-GP', 'French', 'Saint Barthelemy'], // cspell:ignore Barthelemy
|
|
260
260
|
['fr-GQ', 'French', 'Equatorial Guinea'],
|
|
261
261
|
['fr-HT', 'French', 'Haiti'],
|
|
262
262
|
['fr-KM', 'French', 'Comoros'],
|
|
@@ -282,7 +282,7 @@ export const codes = [
|
|
|
282
282
|
['fr-TG', 'French', 'Togo'],
|
|
283
283
|
['fr-TN', 'French', 'Tunisia'],
|
|
284
284
|
['fr-VU', 'French', 'Vanuatu'],
|
|
285
|
-
['fr-WF', 'French', 'Wallis and Futuna'],
|
|
285
|
+
['fr-WF', 'French', 'Wallis and Futuna'], // cspell:ignore Futuna
|
|
286
286
|
['fr-YT', 'French', 'Mayotte'],
|
|
287
287
|
['fy', 'Western Frisian'],
|
|
288
288
|
['fy-NL', 'Western Frisian', 'Netherlands'],
|
|
@@ -322,7 +322,7 @@ export const codes = [
|
|
|
322
322
|
['it', 'Italian'],
|
|
323
323
|
['it-CH', 'Italian', 'Switzerland'],
|
|
324
324
|
['it-IT', 'Italian', 'Italy'],
|
|
325
|
-
['it-SM', 'Italian', 'San Marino'],
|
|
325
|
+
['it-SM', 'Italian', 'San Marino'], // cspell:ignore Marino
|
|
326
326
|
['it-VA', 'Italian', 'Vatican City'],
|
|
327
327
|
['ja', 'Japanese'],
|
|
328
328
|
['ja-JP', 'Japanese', 'Japan'],
|
|
@@ -332,7 +332,7 @@ export const codes = [
|
|
|
332
332
|
['ki-KE', 'Kikuyu', 'Kenya'],
|
|
333
333
|
['kk', 'Kazakh'],
|
|
334
334
|
['kk-KZ', 'Kazakh', 'Kazakhstan'],
|
|
335
|
-
['kl', 'Kalaallisut'],
|
|
335
|
+
['kl', 'Kalaallisut'], // cspell:ignore Kalaallisut
|
|
336
336
|
['kl-GL', 'Kalaallisut', 'Greenland'],
|
|
337
337
|
['km', 'Central Khmer'],
|
|
338
338
|
['km-KH', 'Central Khmer', 'Cambodia'],
|
|
@@ -347,11 +347,11 @@ export const codes = [
|
|
|
347
347
|
['kw-GB', 'Cornish', 'United Kingdom'],
|
|
348
348
|
['ky', 'Kirghiz'],
|
|
349
349
|
['ky-KG', 'Kirghiz', 'Kyrgyzstan'],
|
|
350
|
-
['lb', 'Luxembourgish'],
|
|
350
|
+
['lb', 'Luxembourgish'], // cspell:ignore Luxembourgish
|
|
351
351
|
['lb-LU', 'Luxembourgish', 'Luxembourg'],
|
|
352
352
|
['lg', 'Ganda'],
|
|
353
353
|
['lg-UG', 'Ganda', 'Uganda'],
|
|
354
|
-
['ln', 'Lingala'],
|
|
354
|
+
['ln', 'Lingala'], // cspell:ignore Lingala
|
|
355
355
|
['ln-AO', 'Lingala', 'Angola'],
|
|
356
356
|
['ln-CD', 'Lingala', 'Congo'],
|
|
357
357
|
['ln-CF', 'Lingala', 'Central African Republic'],
|
|
@@ -360,7 +360,7 @@ export const codes = [
|
|
|
360
360
|
['lo-LA', 'Lao', 'Laos'],
|
|
361
361
|
['lt', 'Lithuanian'],
|
|
362
362
|
['lt-LT', 'Lithuanian', 'Lithuania'],
|
|
363
|
-
['lu', 'Luba-Katanga'],
|
|
363
|
+
['lu', 'Luba-Katanga'], // cspell:ignore Luba
|
|
364
364
|
['lu-CD', 'Luba-Katanga', 'Congo'],
|
|
365
365
|
['lv', 'Latvian'],
|
|
366
366
|
['lv-LV', 'Latvian', 'Latvia'],
|
|
@@ -382,10 +382,10 @@ export const codes = [
|
|
|
382
382
|
['mt-MT', 'Maltese', 'Malta'],
|
|
383
383
|
['my', 'Burmese'],
|
|
384
384
|
['my-MM', 'Burmese', 'Myanmar (Burma)'],
|
|
385
|
-
['nb', 'Bokmål Norwegian'],
|
|
385
|
+
['nb', 'Bokmål Norwegian'], // cspell:ignore Bokmål
|
|
386
386
|
['nb-NO', 'Bokmål Norwegian', 'Norway'],
|
|
387
387
|
['nb-SJ', 'Bokmål Norwegian', 'Svalbard'],
|
|
388
|
-
['nd', 'Ndebele, North'],
|
|
388
|
+
['nd', 'Ndebele, North'], // cspell:ignore Ndebele
|
|
389
389
|
['nd-ZW', 'Ndebele, North', 'Zimbabwe'],
|
|
390
390
|
['ne', 'Nepali'],
|
|
391
391
|
['ne-IN', 'Nepali', 'India'],
|
|
@@ -400,12 +400,12 @@ export const codes = [
|
|
|
400
400
|
['nl-SX', 'Dutch'],
|
|
401
401
|
['nn', 'Norwegian Nynorsk'],
|
|
402
402
|
['nn-NO', 'Norwegian Nynorsk', 'Norway'],
|
|
403
|
-
['om', 'Oromo'],
|
|
403
|
+
['om', 'Oromo'], // cspell:ignore Oromo
|
|
404
404
|
['om-ET', 'Oromo', 'Ethiopia'],
|
|
405
405
|
['om-KE', 'Oromo', 'Kenya'],
|
|
406
406
|
['or', 'Oriya'],
|
|
407
407
|
['or-IN', 'Oriya', 'India'],
|
|
408
|
-
['os', 'Ossetian'],
|
|
408
|
+
['os', 'Ossetian'], // cspell:ignore Ossetian
|
|
409
409
|
['os-GE', 'Ossetian', 'Georgia'],
|
|
410
410
|
['os-RU', 'Ossetian', 'Russia'],
|
|
411
411
|
['pa', 'Panjabi'],
|
|
@@ -413,7 +413,7 @@ export const codes = [
|
|
|
413
413
|
['pa-PK', 'Panjabi', 'Pakistan'],
|
|
414
414
|
['pl', 'Polish'],
|
|
415
415
|
['pl-PL', 'Polish', 'Poland'],
|
|
416
|
-
['ps', 'Pushto'],
|
|
416
|
+
['ps', 'Pushto'], // cspell:ignore Pushto
|
|
417
417
|
['ps-AF', 'Pushto', 'Afghanistan'],
|
|
418
418
|
['pt', 'Portuguese'],
|
|
419
419
|
['pt-AO', 'Portuguese', 'Angola'],
|
|
@@ -427,14 +427,14 @@ export const codes = [
|
|
|
427
427
|
['pt-MZ', 'Portuguese', 'Mozambique'],
|
|
428
428
|
['pt-PT', 'Portuguese', 'Portugal'],
|
|
429
429
|
['pt-ST', 'Portuguese', 'Sao Tome and Principe'],
|
|
430
|
-
['pt-TL', 'Portuguese', 'Timor-Leste (East Timor)'],
|
|
430
|
+
['pt-TL', 'Portuguese', 'Timor-Leste (East Timor)'], // cspell:ignore Leste
|
|
431
431
|
['qu', 'Quechua'],
|
|
432
432
|
['qu-BO', 'Quechua', 'Bolivia'],
|
|
433
433
|
['qu-EC', 'Quechua', 'Ecuador'],
|
|
434
434
|
['qu-PE', 'Quechua', 'Peru'],
|
|
435
435
|
['rm', 'Romansh'],
|
|
436
436
|
['rm-CH', 'Romansh', 'Switzerland'],
|
|
437
|
-
['rn', 'Rundi'],
|
|
437
|
+
['rn', 'Rundi'], // cspell:ignore Rundi
|
|
438
438
|
['rn-BI', 'Rundi', 'Burundi'],
|
|
439
439
|
['ro', 'Romanian'],
|
|
440
440
|
['ro-MD', 'Romanian', 'Moldova'],
|
|
@@ -446,21 +446,21 @@ export const codes = [
|
|
|
446
446
|
['ru-MD', 'Russian', 'Moldova'],
|
|
447
447
|
['ru-RU', 'Russian', 'Russia'],
|
|
448
448
|
['ru-UA', 'Russian', 'Ukraine'],
|
|
449
|
-
['rw', 'Kinyarwanda'],
|
|
449
|
+
['rw', 'Kinyarwanda'], // cspell:ignore Kinyarwanda
|
|
450
450
|
['rw-RW', 'Kinyarwanda', 'Rwanda'],
|
|
451
|
-
['se', 'Northern Sami'],
|
|
451
|
+
['se', 'Northern Sami'], // cspell:ignore Sami
|
|
452
452
|
['se-FI', 'Northern Sami', 'Finland'],
|
|
453
453
|
['se-NO', 'Northern Sami', 'Norway'],
|
|
454
454
|
['se-SE', 'Northern Sami', 'Sweden'],
|
|
455
|
-
['sg', 'Sango'],
|
|
455
|
+
['sg', 'Sango'], // cspell:ignore Sango
|
|
456
456
|
['sg-CF', 'Sango', 'Central African Republic'],
|
|
457
|
-
['si', 'Sinhala'],
|
|
457
|
+
['si', 'Sinhala'], // cspell:ignore Sinhala
|
|
458
458
|
['si-LK', 'Sinhala', 'Sri Lanka'],
|
|
459
459
|
['sk', 'Slovak'],
|
|
460
460
|
['sk-SK', 'Slovak', 'Slovakia'],
|
|
461
461
|
['sl', 'Slovenian'],
|
|
462
462
|
['sl-SI', 'Slovenian', 'Slovenia'],
|
|
463
|
-
['sn', 'Shona'],
|
|
463
|
+
['sn', 'Shona'], // cspell:ignore Shona
|
|
464
464
|
['sn-ZW', 'Shona', 'Zimbabwe'],
|
|
465
465
|
['so', 'Somali'],
|
|
466
466
|
['so-DJ', 'Somali', 'Djibouti'],
|
|
@@ -477,7 +477,7 @@ export const codes = [
|
|
|
477
477
|
['sr-RS', 'Serbian', 'Serbia'],
|
|
478
478
|
['sr-XK', 'Serbian'],
|
|
479
479
|
['sv', 'Swedish'],
|
|
480
|
-
['sv-AX', 'Swedish', 'Aland'],
|
|
480
|
+
['sv-AX', 'Swedish', 'Aland'], // cspell:ignore Aland
|
|
481
481
|
['sv-FI', 'Swedish', 'Finland'],
|
|
482
482
|
['sv-SE', 'Swedish', 'Sweden'],
|
|
483
483
|
['sw', 'Swahili'],
|
|
@@ -516,7 +516,7 @@ export const codes = [
|
|
|
516
516
|
['uz-UZ', 'Uzbek', 'Uzbekistan'],
|
|
517
517
|
['vi', 'Vietnamese'],
|
|
518
518
|
['vi-VN', 'Vietnamese', 'Vietnam'],
|
|
519
|
-
['vo', 'Volapük'],
|
|
519
|
+
['vo', 'Volapük'], // cspell:ignore Volapük
|
|
520
520
|
['yi', 'Yiddish'],
|
|
521
521
|
['yi-1', 'Yiddish'],
|
|
522
522
|
['yo', 'Yoruba'],
|
package/dist/lib/trie.js
CHANGED
|
@@ -8,10 +8,16 @@ import { replaceAllFactory } from './utils/util.js';
|
|
|
8
8
|
import { walker } from './walker/index.js';
|
|
9
9
|
const defaultLegacyMinCompoundLength = 3;
|
|
10
10
|
export class Trie {
|
|
11
|
+
root;
|
|
12
|
+
count;
|
|
13
|
+
_options;
|
|
14
|
+
_findOptionsDefaults;
|
|
15
|
+
_findOptionsExact;
|
|
16
|
+
isLegacy;
|
|
17
|
+
hasForbidden;
|
|
11
18
|
constructor(root, count) {
|
|
12
19
|
this.root = root;
|
|
13
20
|
this.count = count;
|
|
14
|
-
this.lastCreateFindOptionsMatchCaseMap = new Map();
|
|
15
21
|
this._options = mergeOptionalWithDefaults(root);
|
|
16
22
|
this.isLegacy = this.calcIsLegacy();
|
|
17
23
|
this.hasForbidden = !!root.c[root.forbiddenWordPrefix];
|
|
@@ -174,6 +180,7 @@ export class Trie {
|
|
|
174
180
|
});
|
|
175
181
|
return findOptions;
|
|
176
182
|
}
|
|
183
|
+
lastCreateFindOptionsMatchCaseMap = new Map();
|
|
177
184
|
createFindOptionsMatchCase(matchCase) {
|
|
178
185
|
const f = this.lastCreateFindOptionsMatchCaseMap.get(matchCase);
|
|
179
186
|
if (f !== undefined)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export class AutoCacheMap extends Map {
|
|
2
|
+
autoFn;
|
|
2
3
|
constructor(autoFn) {
|
|
3
4
|
super();
|
|
4
5
|
this.autoFn = autoFn;
|
|
@@ -13,6 +14,7 @@ export class AutoCacheMap extends Map {
|
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
export class AutoCacheWeakMap extends WeakMap {
|
|
17
|
+
autoFn;
|
|
16
18
|
constructor(autoFn) {
|
|
17
19
|
super();
|
|
18
20
|
this.autoFn = autoFn;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export class SecondChanceCache {
|
|
2
|
+
maxL0Size;
|
|
3
|
+
map0 = new Map();
|
|
4
|
+
map1 = new Map();
|
|
2
5
|
constructor(maxL0Size) {
|
|
3
6
|
this.maxL0Size = maxL0Size;
|
|
4
|
-
this.map0 = new Map();
|
|
5
|
-
this.map1 = new Map();
|
|
6
7
|
}
|
|
7
8
|
has(key) {
|
|
8
9
|
if (this.map0.has(key))
|
|
9
10
|
return true;
|
|
10
11
|
if (this.map1.has(key)) {
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
12
12
|
this.set(key, this.get1(key));
|
|
13
13
|
return true;
|
|
14
14
|
}
|
|
@@ -41,7 +41,6 @@ export class SecondChanceCache {
|
|
|
41
41
|
}
|
|
42
42
|
get1(key) {
|
|
43
43
|
if (this.map1.has(key)) {
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
45
44
|
const v = this.map1.get(key);
|
|
46
45
|
this.map1.delete(key);
|
|
47
46
|
this.map0.set(key, v);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell-trie-lib",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "Trie Data Structure to support cspell.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -46,18 +46,18 @@
|
|
|
46
46
|
},
|
|
47
47
|
"homepage": "https://github.com/streetsidesoftware/cspell#readme",
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@cspell/cspell-pipe": "
|
|
50
|
-
"@cspell/cspell-types": "
|
|
49
|
+
"@cspell/cspell-pipe": "8.1.0",
|
|
50
|
+
"@cspell/cspell-types": "8.1.0",
|
|
51
51
|
"gensequence": "^6.0.0"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
|
-
"node": ">=
|
|
54
|
+
"node": ">=18"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@cspell/dict-en_us": "^4.3.
|
|
57
|
+
"@cspell/dict-en_us": "^4.3.12",
|
|
58
58
|
"@cspell/dict-es-es": "^2.3.0",
|
|
59
59
|
"@cspell/dict-nl-nl": "^2.3.0",
|
|
60
|
-
"import-meta-resolve": "^
|
|
60
|
+
"import-meta-resolve": "^4.0.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "28568808deaf39b9ffa71fd0f722441ff1b8c794"
|
|
63
63
|
}
|