cspell-lib 5.12.0-alpha.0 → 5.12.3
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.
|
@@ -26,10 +26,12 @@ const fileReader_1 = require("../util/fileReader");
|
|
|
26
26
|
const createSpellingDictionary_1 = require("./createSpellingDictionary");
|
|
27
27
|
const SpellingDictionaryError_1 = require("./SpellingDictionaryError");
|
|
28
28
|
const SpellingDictionaryFromTrie_1 = require("./SpellingDictionaryFromTrie");
|
|
29
|
+
const gensequence_1 = require("gensequence");
|
|
29
30
|
const MAX_AGE = 10000;
|
|
30
31
|
const loaders = {
|
|
31
32
|
S: loadSimpleWordList,
|
|
32
|
-
C:
|
|
33
|
+
C: legacyWordList,
|
|
34
|
+
W: wordsPerLineWordList,
|
|
33
35
|
T: loadTrie,
|
|
34
36
|
default: loadSimpleWordList,
|
|
35
37
|
};
|
|
@@ -47,7 +49,7 @@ function loadDictionary(uri, options) {
|
|
|
47
49
|
exports.loadDictionary = loadDictionary;
|
|
48
50
|
const importantOptionKeys = ['noSuggest', 'useCompounds'];
|
|
49
51
|
function calcKey(uri, options) {
|
|
50
|
-
const loaderType = determineType(uri);
|
|
52
|
+
const loaderType = determineType(uri, options);
|
|
51
53
|
const optValues = importantOptionKeys.map((k) => { var _a; return ((_a = options[k]) === null || _a === void 0 ? void 0 : _a.toString()) || ''; });
|
|
52
54
|
const parts = [uri, loaderType].concat(optValues);
|
|
53
55
|
return parts.join('|');
|
|
@@ -92,16 +94,38 @@ function loadEntry(uri, options, now = Date.now()) {
|
|
|
92
94
|
dictionary,
|
|
93
95
|
};
|
|
94
96
|
}
|
|
95
|
-
function determineType(uri) {
|
|
96
|
-
const
|
|
97
|
+
function determineType(uri, opts) {
|
|
98
|
+
const t = (opts.type && opts.type in loaders && opts.type) || 'S';
|
|
99
|
+
const defLoaderType = t;
|
|
100
|
+
const defType = uri.endsWith('.trie.gz') ? 'T' : uri.endsWith('.txt.gz') ? defLoaderType : defLoaderType;
|
|
97
101
|
const regTrieTest = /\.trie\b/i;
|
|
98
102
|
return regTrieTest.test(uri) ? 'T' : defType;
|
|
99
103
|
}
|
|
100
104
|
function load(uri, options) {
|
|
101
|
-
const type = determineType(uri);
|
|
105
|
+
const type = determineType(uri, options);
|
|
102
106
|
const loader = loaders[type] || loaders.default;
|
|
103
107
|
return loader(uri, options);
|
|
104
108
|
}
|
|
109
|
+
async function legacyWordList(filename, options) {
|
|
110
|
+
const lines = await (0, fileReader_1.readLines)(filename);
|
|
111
|
+
const words = (0, gensequence_1.genSequence)(lines)
|
|
112
|
+
// Remove comments
|
|
113
|
+
.map((line) => line.replace(/#.*/g, ''))
|
|
114
|
+
// Split on everything else
|
|
115
|
+
.concatMap((line) => line.split(/[^\w\p{L}\p{M}'’]+/gu))
|
|
116
|
+
.filter((word) => !!word);
|
|
117
|
+
return (0, createSpellingDictionary_1.createSpellingDictionary)(words, determineName(filename, options), filename, options);
|
|
118
|
+
}
|
|
119
|
+
async function wordsPerLineWordList(filename, options) {
|
|
120
|
+
const lines = await (0, fileReader_1.readLines)(filename);
|
|
121
|
+
const words = (0, gensequence_1.genSequence)(lines)
|
|
122
|
+
// Remove comments
|
|
123
|
+
.map((line) => line.replace(/#.*/g, ''))
|
|
124
|
+
// Split on everything else
|
|
125
|
+
.concatMap((line) => line.split(/\s+/gu))
|
|
126
|
+
.filter((word) => !!word);
|
|
127
|
+
return (0, createSpellingDictionary_1.createSpellingDictionary)(words, determineName(filename, options), filename, options);
|
|
128
|
+
}
|
|
105
129
|
async function loadSimpleWordList(filename, options) {
|
|
106
130
|
const lines = await (0, fileReader_1.readLines)(filename);
|
|
107
131
|
return (0, createSpellingDictionary_1.createSpellingDictionary)(lines, determineName(filename, options), filename, options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell-lib",
|
|
3
|
-
"version": "5.12.
|
|
3
|
+
"version": "5.12.3",
|
|
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",
|
|
@@ -47,15 +47,15 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://github.com/streetsidesoftware/cspell#readme",
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@cspell/cspell-bundled-dicts": "^5.12.
|
|
51
|
-
"@cspell/cspell-types": "^5.12.
|
|
50
|
+
"@cspell/cspell-bundled-dicts": "^5.12.3",
|
|
51
|
+
"@cspell/cspell-types": "^5.12.3",
|
|
52
52
|
"clear-module": "^4.1.1",
|
|
53
53
|
"comment-json": "^4.1.1",
|
|
54
54
|
"configstore": "^5.0.1",
|
|
55
55
|
"cosmiconfig": "^7.0.1",
|
|
56
|
-
"cspell-glob": "^5.12.
|
|
57
|
-
"cspell-io": "^5.12.
|
|
58
|
-
"cspell-trie-lib": "^5.12.
|
|
56
|
+
"cspell-glob": "^5.12.3",
|
|
57
|
+
"cspell-io": "^5.12.3",
|
|
58
|
+
"cspell-trie-lib": "^5.12.3",
|
|
59
59
|
"find-up": "^5.0.0",
|
|
60
60
|
"fs-extra": "^10.0.0",
|
|
61
61
|
"gensequence": "^3.1.1",
|
|
@@ -79,12 +79,12 @@
|
|
|
79
79
|
"@types/configstore": "^5.0.1",
|
|
80
80
|
"@types/fs-extra": "^9.0.13",
|
|
81
81
|
"@types/jest": "^27.0.2",
|
|
82
|
-
"@types/node": "^16.10.
|
|
82
|
+
"@types/node": "^16.10.3",
|
|
83
83
|
"cspell-dict-nl-nl": "^1.1.2",
|
|
84
|
-
"jest": "^27.2.
|
|
84
|
+
"jest": "^27.2.5",
|
|
85
85
|
"lorem-ipsum": "^2.0.4",
|
|
86
86
|
"rimraf": "^3.0.2",
|
|
87
87
|
"ts-jest": "^27.0.5"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "6c424aed933adb8d983ab09dd45042d63d7a5cd8"
|
|
90
90
|
}
|