cspell-dictionary 8.2.4 → 8.3.1
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.
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
function expand(pattern, options = { begin: '(', end: ')', sep: '|' }, start = 0) {
|
|
2
|
+
const len = pattern.length;
|
|
3
|
+
const parts = [];
|
|
4
|
+
function push(word) {
|
|
5
|
+
if (Array.isArray(word)) {
|
|
6
|
+
parts.push(...word);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
parts.push(word);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
let i = start;
|
|
13
|
+
let curWord = '';
|
|
14
|
+
while (i < len) {
|
|
15
|
+
const ch = pattern[i++];
|
|
16
|
+
if (ch === options.end) {
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
if (ch === options.begin) {
|
|
20
|
+
const nested = expand(pattern, options, i);
|
|
21
|
+
i = nested.idx;
|
|
22
|
+
curWord = nested.parts.flatMap((p) => (Array.isArray(curWord) ? curWord.map((w) => w + p) : [curWord + p]));
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (ch === options.sep) {
|
|
26
|
+
push(curWord);
|
|
27
|
+
curWord = '';
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
curWord = Array.isArray(curWord) ? curWord.map((w) => w + ch) : curWord + ch;
|
|
31
|
+
}
|
|
32
|
+
push(curWord);
|
|
33
|
+
return { parts, idx: i };
|
|
34
|
+
}
|
|
35
|
+
export function expandBraces(pattern, options = { begin: '(', end: ')', sep: '|' }) {
|
|
36
|
+
return expand(pattern, options).parts;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=braceExpansion.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell-dictionary",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.1",
|
|
4
4
|
"description": "A spelling dictionary library useful for checking words and getting suggestions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"node": ">=18"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@cspell/cspell-pipe": "8.
|
|
50
|
-
"@cspell/cspell-types": "8.
|
|
51
|
-
"cspell-trie-lib": "8.
|
|
49
|
+
"@cspell/cspell-pipe": "8.3.1",
|
|
50
|
+
"@cspell/cspell-types": "8.3.1",
|
|
51
|
+
"cspell-trie-lib": "8.3.1",
|
|
52
52
|
"fast-equals": "^5.0.1",
|
|
53
53
|
"gensequence": "^6.0.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "7136c39fd5f47c2acd44bec0bede924e55e1a107"
|
|
56
56
|
}
|