hunspell-reader 7.0.0-alpha.1 → 7.0.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/bin.js +1 -3
- package/dist/IterableHunspellReader.d.ts +4 -4
- package/dist/IterableHunspellReader.js +13 -40
- package/dist/aff.d.ts +2 -2
- package/dist/aff.js +24 -61
- package/dist/affDef.js +1 -2
- package/dist/affReader.d.ts +2 -2
- package/dist/affReader.js +18 -26
- package/dist/affToDicInfo.d.ts +1 -1
- package/dist/affToDicInfo.js +10 -14
- package/dist/app.js +11 -12
- package/dist/commandDictInfo.js +9 -13
- package/dist/commandWords.js +17 -21
- package/dist/converter.js +1 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -13
- package/dist/iterableToStream.d.ts +2 -2
- package/dist/iterableToStream.js +3 -30
- package/dist/textUtils.js +4 -11
- package/dist/types.js +1 -2
- package/dist/util.js +6 -15
- package/package.json +19 -18
package/bin.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Sequence } from 'gensequence';
|
|
2
|
-
import type { Aff } from './aff';
|
|
3
|
-
import type { AffWord } from './affDef';
|
|
4
|
-
import type { WordInfo } from './types';
|
|
5
|
-
export { WordInfo } from './types';
|
|
2
|
+
import type { Aff } from './aff.js';
|
|
3
|
+
import type { AffWord } from './affDef.js';
|
|
4
|
+
import type { WordInfo } from './types.js';
|
|
5
|
+
export { WordInfo } from './types.js';
|
|
6
6
|
export interface HunspellSrcData {
|
|
7
7
|
/** The Aff rules to use with the dictionary entries */
|
|
8
8
|
aff: Aff;
|
|
@@ -1,36 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.createMatchingWordsFilter = exports.IterableHunspellReader = void 0;
|
|
27
|
-
const fs = __importStar(require("fs/promises"));
|
|
28
|
-
const gensequence_1 = require("gensequence");
|
|
29
|
-
const iconv_lite_1 = require("iconv-lite");
|
|
30
|
-
const affReader_1 = require("./affReader");
|
|
31
|
-
const util_1 = require("./util");
|
|
1
|
+
import * as fs from 'fs/promises';
|
|
2
|
+
import { genSequence } from 'gensequence';
|
|
3
|
+
import pkgIconvLite from 'iconv-lite';
|
|
4
|
+
import { parseAffFileToAff } from './affReader.js';
|
|
5
|
+
import { filterOrderedList } from './util.js';
|
|
6
|
+
const { decode } = pkgIconvLite;
|
|
32
7
|
const defaultEncoding = 'UTF-8';
|
|
33
|
-
class IterableHunspellReader {
|
|
8
|
+
export class IterableHunspellReader {
|
|
34
9
|
constructor(src) {
|
|
35
10
|
this.src = src;
|
|
36
11
|
this.aff = src.aff;
|
|
@@ -52,7 +27,7 @@ class IterableHunspellReader {
|
|
|
52
27
|
* @internal
|
|
53
28
|
*/
|
|
54
29
|
dicWordsSeq() {
|
|
55
|
-
return
|
|
30
|
+
return genSequence(this.src.dic).map((line) => {
|
|
56
31
|
const [word, rules] = line.split('/', 2);
|
|
57
32
|
return { word, rules, prefixes: [], suffixes: [] };
|
|
58
33
|
});
|
|
@@ -89,7 +64,7 @@ class IterableHunspellReader {
|
|
|
89
64
|
* It is mostly used for monitoring progress in combination with `size`.
|
|
90
65
|
*/
|
|
91
66
|
seqTransformDictionaryEntries(tapPreApplyRules, maxDepth) {
|
|
92
|
-
const seq =
|
|
67
|
+
const seq = genSequence(this.src.dic);
|
|
93
68
|
let count = 0;
|
|
94
69
|
const dicWords = tapPreApplyRules ? seq.map((a) => (tapPreApplyRules(a, count++), a)) : seq;
|
|
95
70
|
return dicWords.map((dicWord) => this.aff.applyRulesToDicEntry(dicWord, maxDepth));
|
|
@@ -128,9 +103,9 @@ class IterableHunspellReader {
|
|
|
128
103
|
* @returns IterableHunspellReader
|
|
129
104
|
*/
|
|
130
105
|
static async createFromFiles(affFile, dicFile) {
|
|
131
|
-
const aff = await
|
|
106
|
+
const aff = await parseAffFileToAff(affFile, defaultEncoding);
|
|
132
107
|
const buffer = await fs.readFile(dicFile);
|
|
133
|
-
const dicFileContent =
|
|
108
|
+
const dicFileContent = decode(buffer, aff.affInfo.SET);
|
|
134
109
|
const dic = dicFileContent
|
|
135
110
|
.split('\n')
|
|
136
111
|
.slice(1) // The first entry is the count of entries.
|
|
@@ -139,9 +114,7 @@ class IterableHunspellReader {
|
|
|
139
114
|
return new IterableHunspellReader({ aff, dic });
|
|
140
115
|
}
|
|
141
116
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return (0, util_1.filterOrderedList)((a, b) => a !== b);
|
|
117
|
+
export function createMatchingWordsFilter() {
|
|
118
|
+
return filterOrderedList((a, b) => a !== b);
|
|
145
119
|
}
|
|
146
|
-
exports.createMatchingWordsFilter = createMatchingWordsFilter;
|
|
147
120
|
//# sourceMappingURL=IterableHunspellReader.js.map
|
package/dist/aff.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AffInfo, AffWord, AffWordFlags, Fx, Rule, Substitution } from './affDef';
|
|
2
|
-
import { Converter } from './converter';
|
|
1
|
+
import type { AffInfo, AffWord, AffWordFlags, Fx, Rule, Substitution } from './affDef.js';
|
|
2
|
+
import { Converter } from './converter.js';
|
|
3
3
|
/** The `word` field in a Converted AffWord has been converted using the OCONV mapping */
|
|
4
4
|
export type ConvertedAffWord = AffWord;
|
|
5
5
|
export declare class Aff {
|
package/dist/aff.js
CHANGED
|
@@ -1,43 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.debug = exports.filterAff = exports.compareAff = exports.asAffWord = exports.flagsToString = exports.affWordToColoredString = exports.logAffWord = exports.processRules = exports.Aff = void 0;
|
|
27
|
-
const GS = __importStar(require("gensequence"));
|
|
28
|
-
const gensequence_1 = require("gensequence");
|
|
29
|
-
const util = __importStar(require("util"));
|
|
30
|
-
const converter_1 = require("./converter");
|
|
31
|
-
const util_1 = require("./util");
|
|
1
|
+
import * as GS from 'gensequence';
|
|
2
|
+
import { genSequence as gs } from 'gensequence';
|
|
3
|
+
import * as util from 'util';
|
|
4
|
+
import { Converter } from './converter.js';
|
|
5
|
+
import { filterOrderedList, isDefined } from './util.js';
|
|
32
6
|
const log = false;
|
|
33
7
|
const DefaultMaxDepth = 5;
|
|
34
|
-
class Aff {
|
|
8
|
+
export class Aff {
|
|
35
9
|
constructor(affInfo) {
|
|
36
10
|
this.affInfo = affInfo;
|
|
37
11
|
this._maxSuffixDepth = DefaultMaxDepth;
|
|
38
12
|
this.rules = processRules(affInfo);
|
|
39
|
-
this._iConv = new
|
|
40
|
-
this._oConv = new
|
|
13
|
+
this._iConv = new Converter(affInfo.ICONV || []);
|
|
14
|
+
this._oConv = new Converter(affInfo.OCONV || []);
|
|
41
15
|
}
|
|
42
16
|
get maxSuffixDepth() {
|
|
43
17
|
return this._maxSuffixDepth;
|
|
@@ -76,7 +50,7 @@ class Aff {
|
|
|
76
50
|
flags: { ...acc.flags, ...rule.flags },
|
|
77
51
|
}), { rulesApplied: affWord.rulesApplied, flags: affWord.flags });
|
|
78
52
|
const rules = this.joinRules(allRules.filter((rule) => !rule.flags).map((rule) => rule.id));
|
|
79
|
-
const affixRules = allRules.map((rule) => rule.sfx || rule.pfx).filter(
|
|
53
|
+
const affixRules = allRules.map((rule) => rule.sfx || rule.pfx).filter(isDefined);
|
|
80
54
|
const wordWithFlags = { word, flags, rulesApplied, rules: '', base, suffix, prefix, dic };
|
|
81
55
|
return [wordWithFlags, ...this.applyAffixesToWord(affixRules, { ...wordWithFlags, rules }, remainingDepth)]
|
|
82
56
|
.filter(({ flags }) => !flags.isNeedAffix)
|
|
@@ -93,10 +67,8 @@ class Aff {
|
|
|
93
67
|
.map(({ id }) => id);
|
|
94
68
|
const combinableSfx = this.joinRules(combinableRules);
|
|
95
69
|
const r = affixRules
|
|
96
|
-
.
|
|
97
|
-
.
|
|
98
|
-
.map((affWord) => this.applyRulesToWord(affWord, remainingDepth - 1))
|
|
99
|
-
.reduce((a, b) => a.concat(b), []);
|
|
70
|
+
.flatMap((affix) => this.applyAffixToWord(affix, affWord, combinableSfx))
|
|
71
|
+
.flatMap((affWord) => this.applyRulesToWord(affWord, remainingDepth - 1));
|
|
100
72
|
return r;
|
|
101
73
|
}
|
|
102
74
|
applyAffixToWord(affix, affWord, combinableSfx) {
|
|
@@ -106,8 +78,7 @@ class Aff {
|
|
|
106
78
|
const matchingSubstitutions = [...affix.substitutionSets.values()].filter((sub) => sub.match.test(word));
|
|
107
79
|
const partialAffWord = { ...affWord, flags, rules: combineRules };
|
|
108
80
|
return matchingSubstitutions
|
|
109
|
-
.
|
|
110
|
-
.reduce((a, b) => a.concat(b), [])
|
|
81
|
+
.flatMap((sub) => sub.substitutions)
|
|
111
82
|
.filter((sub) => sub.remove === '0' || sub.replace.test(word))
|
|
112
83
|
.map((sub) => this.substitute(affix, partialAffWord, sub))
|
|
113
84
|
.map((affWord) => logAffWord(affWord, 'applyAffixToWord'));
|
|
@@ -148,7 +119,7 @@ class Aff {
|
|
|
148
119
|
const rulesToSplit = AF[idx] || rules;
|
|
149
120
|
return this.separateRules(rulesToSplit)
|
|
150
121
|
.map((key) => this.rules.get(key))
|
|
151
|
-
.filter(
|
|
122
|
+
.filter(isDefined);
|
|
152
123
|
}
|
|
153
124
|
joinRules(rules) {
|
|
154
125
|
switch (this.affInfo.FLAG) {
|
|
@@ -175,7 +146,6 @@ class Aff {
|
|
|
175
146
|
return this._oConv;
|
|
176
147
|
}
|
|
177
148
|
}
|
|
178
|
-
exports.Aff = Aff;
|
|
179
149
|
function signature(aff) {
|
|
180
150
|
const { word, flags } = aff;
|
|
181
151
|
const sig = Object.entries(flags)
|
|
@@ -185,11 +155,11 @@ function signature(aff) {
|
|
|
185
155
|
.join('');
|
|
186
156
|
return word + '|' + sig;
|
|
187
157
|
}
|
|
188
|
-
function processRules(affInfo) {
|
|
189
|
-
const sfxRules = (
|
|
158
|
+
export function processRules(affInfo) {
|
|
159
|
+
const sfxRules = gs(affInfo.SFX || [])
|
|
190
160
|
.map(([, sfx]) => sfx)
|
|
191
161
|
.map((sfx) => ({ id: sfx.id, type: 'sfx', sfx }));
|
|
192
|
-
const pfxRules = (
|
|
162
|
+
const pfxRules = gs(affInfo.PFX || [])
|
|
193
163
|
.map(([, pfx]) => pfx)
|
|
194
164
|
.map((pfx) => ({ id: pfx.id, type: 'pfx', pfx }));
|
|
195
165
|
const flagRules = GS.sequenceFromObject(affInfo)
|
|
@@ -205,7 +175,6 @@ function processRules(affInfo) {
|
|
|
205
175
|
}, new Map());
|
|
206
176
|
return rules;
|
|
207
177
|
}
|
|
208
|
-
exports.processRules = processRules;
|
|
209
178
|
const affFlag = {
|
|
210
179
|
KEEPCASE: { isKeepCase: true },
|
|
211
180
|
WARN: { isWarning: true },
|
|
@@ -251,7 +220,7 @@ const _FlagToLongStringMap = {
|
|
|
251
220
|
};
|
|
252
221
|
const flagToStringMap = _FlagToStringMap;
|
|
253
222
|
const flagToLongStringMap = _FlagToLongStringMap;
|
|
254
|
-
function logAffWord(affWord, message) {
|
|
223
|
+
export function logAffWord(affWord, message) {
|
|
255
224
|
/* istanbul ignore if */
|
|
256
225
|
if (log) {
|
|
257
226
|
const dump = util.inspect(affWord, { showHidden: false, depth: 5, colors: true });
|
|
@@ -259,24 +228,21 @@ function logAffWord(affWord, message) {
|
|
|
259
228
|
}
|
|
260
229
|
return affWord;
|
|
261
230
|
}
|
|
262
|
-
exports.logAffWord = logAffWord;
|
|
263
231
|
/* istanbul ignore next */
|
|
264
|
-
function affWordToColoredString(affWord) {
|
|
232
|
+
export function affWordToColoredString(affWord) {
|
|
265
233
|
return util
|
|
266
234
|
.inspect({ ...affWord, flags: flagsToString(affWord.flags) }, { showHidden: false, depth: 5, colors: true })
|
|
267
235
|
.replace(/(\s|\n|\r)+/g, ' ');
|
|
268
236
|
}
|
|
269
|
-
exports.affWordToColoredString = affWordToColoredString;
|
|
270
237
|
/* istanbul ignore next */
|
|
271
|
-
function flagsToString(flags) {
|
|
238
|
+
export function flagsToString(flags) {
|
|
272
239
|
return [...Object.entries(flags)]
|
|
273
240
|
.filter(([, v]) => !!v)
|
|
274
241
|
.map(([k]) => flagToLongStringMap[k])
|
|
275
242
|
.sort()
|
|
276
243
|
.join(':');
|
|
277
244
|
}
|
|
278
|
-
|
|
279
|
-
function asAffWord(word, rules = '', flags = {}) {
|
|
245
|
+
export function asAffWord(word, rules = '', flags = {}) {
|
|
280
246
|
return {
|
|
281
247
|
word,
|
|
282
248
|
base: word,
|
|
@@ -288,8 +254,7 @@ function asAffWord(word, rules = '', flags = {}) {
|
|
|
288
254
|
dic: rules ? word + '/' + rules : word,
|
|
289
255
|
};
|
|
290
256
|
}
|
|
291
|
-
|
|
292
|
-
function compareAff(a, b) {
|
|
257
|
+
export function compareAff(a, b) {
|
|
293
258
|
if (a.word !== b.word) {
|
|
294
259
|
return a.word < b.word ? -1 : 1;
|
|
295
260
|
}
|
|
@@ -297,16 +262,14 @@ function compareAff(a, b) {
|
|
|
297
262
|
const sigB = signature(b);
|
|
298
263
|
return sigA < sigB ? -1 : sigA > sigB ? 1 : 0;
|
|
299
264
|
}
|
|
300
|
-
exports.compareAff = compareAff;
|
|
301
265
|
/**
|
|
302
266
|
* Returns a filter function that will filter adjacent AffWords
|
|
303
267
|
* It compares the word and the flags.
|
|
304
268
|
*/
|
|
305
|
-
function filterAff() {
|
|
306
|
-
return
|
|
269
|
+
export function filterAff() {
|
|
270
|
+
return filterOrderedList((a, b) => a.word !== b.word || signature(a) !== signature(b));
|
|
307
271
|
}
|
|
308
|
-
|
|
309
|
-
exports.debug = {
|
|
272
|
+
export const debug = {
|
|
310
273
|
signature,
|
|
311
274
|
};
|
|
312
275
|
function removeNeedAffix(flags) {
|
package/dist/affDef.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// cspell:words uppercased
|
|
3
2
|
// cspell:words KEEPCASE WARN NEEDAFFIX FORCEUCASE FORBIDDENWORD NOSUGGEST WORDCHARS
|
|
4
3
|
// cspell:words COMPOUNDBEGIN COMPOUNDMIDDLE COMPOUNDEND COMPOUNDPERMITFLAG COMPOUNDFORBIDFLAG
|
|
5
4
|
// cspell:words MAXDIFF COMPOUNDMIN COMPOUNDRULE COMPOUNDFLAG COMPOUNDLAST FORBIDWARN
|
|
6
|
-
|
|
5
|
+
export {};
|
|
7
6
|
//# sourceMappingURL=affDef.js.map
|
package/dist/affReader.d.ts
CHANGED
package/dist/affReader.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const assert_1 = __importDefault(require("assert"));
|
|
8
|
-
const promises_1 = require("fs/promises");
|
|
9
|
-
const iconv_lite_1 = require("iconv-lite");
|
|
10
|
-
const aff_1 = require("./aff");
|
|
11
|
-
const util_1 = require("./util");
|
|
1
|
+
import assert from 'assert';
|
|
2
|
+
import { readFile } from 'fs/promises';
|
|
3
|
+
import pkgIconvLite from 'iconv-lite';
|
|
4
|
+
import { Aff } from './aff.js';
|
|
5
|
+
import { cleanObject, isDefined } from './util.js';
|
|
6
|
+
const { decode } = pkgIconvLite;
|
|
12
7
|
const fixRegex = {
|
|
13
8
|
SFX: { m: /$/, r: '$' },
|
|
14
9
|
PFX: { m: /^/, r: '^' },
|
|
@@ -97,7 +92,7 @@ function tablePfxOrSfx(fieldValue, line) {
|
|
|
97
92
|
return fieldValue;
|
|
98
93
|
}
|
|
99
94
|
const fixRuleSet = fieldValue.get(subField);
|
|
100
|
-
(
|
|
95
|
+
assert(fixRuleSet);
|
|
101
96
|
const substitutionSets = fixRuleSet.substitutionSets;
|
|
102
97
|
const ruleAsString = rule.condition.source;
|
|
103
98
|
if (!substitutionSets.has(ruleAsString)) {
|
|
@@ -107,7 +102,7 @@ function tablePfxOrSfx(fieldValue, line) {
|
|
|
107
102
|
});
|
|
108
103
|
}
|
|
109
104
|
const substitutionSet = substitutionSets.get(ruleAsString);
|
|
110
|
-
(
|
|
105
|
+
assert(substitutionSet);
|
|
111
106
|
const [attachText, attachRules] = rule.affix.split('/', 2);
|
|
112
107
|
substitutionSet.substitutions.push({
|
|
113
108
|
remove: rule.stripping,
|
|
@@ -203,7 +198,7 @@ function toRep(values) {
|
|
|
203
198
|
return values.map((v) => ({ match: v[0], replaceWith: v[1] }));
|
|
204
199
|
}
|
|
205
200
|
function toSingleStrings(values) {
|
|
206
|
-
return values.map((v) => v[0]).filter(
|
|
201
|
+
return values.map((v) => v[0]).filter(isDefined);
|
|
207
202
|
}
|
|
208
203
|
function toAffMap(values) {
|
|
209
204
|
return toSingleStrings(values);
|
|
@@ -298,19 +293,18 @@ function collectionToAffInfo(affFieldCollectionTable, encoding) {
|
|
|
298
293
|
WARN: affFieldCollectionTable.WARN.getValue(),
|
|
299
294
|
WORDCHARS: affFieldCollectionTable.WORDCHARS.getValue(),
|
|
300
295
|
};
|
|
301
|
-
return
|
|
296
|
+
return cleanObject(result);
|
|
302
297
|
}
|
|
303
|
-
async function parseAffFile(filename, encoding = UTF8) {
|
|
304
|
-
const buffer = await
|
|
305
|
-
const file =
|
|
298
|
+
export async function parseAffFile(filename, encoding = UTF8) {
|
|
299
|
+
const buffer = await readFile(filename);
|
|
300
|
+
const file = decode(buffer, encoding);
|
|
306
301
|
const affInfo = parseAff(file, encoding);
|
|
307
302
|
if (affInfo.SET && affInfo.SET.toLowerCase() !== encoding.toLowerCase()) {
|
|
308
|
-
return parseAff(
|
|
303
|
+
return parseAff(decode(buffer, affInfo.SET.toLowerCase()), affInfo.SET);
|
|
309
304
|
}
|
|
310
305
|
return affInfo;
|
|
311
306
|
}
|
|
312
|
-
|
|
313
|
-
function parseAff(affFileContent, encoding = UTF8) {
|
|
307
|
+
export function parseAff(affFileContent, encoding = UTF8) {
|
|
314
308
|
const lines = affFileContent.split(/\r?\n/g);
|
|
315
309
|
const affFieldCollectionTable = createAffFieldTable();
|
|
316
310
|
affFieldCollectionTable.SET.addLine({ option: 'SET', value: encoding });
|
|
@@ -325,17 +319,15 @@ function parseAff(affFileContent, encoding = UTF8) {
|
|
|
325
319
|
});
|
|
326
320
|
return collectionToAffInfo(affFieldCollectionTable, encoding);
|
|
327
321
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
return parseAffFile(filename, encoding).then((affInfo) => new aff_1.Aff(affInfo));
|
|
322
|
+
export function parseAffFileToAff(filename, encoding) {
|
|
323
|
+
return parseAffFile(filename, encoding).then((affInfo) => new Aff(affInfo));
|
|
331
324
|
}
|
|
332
|
-
exports.parseAffFileToAff = parseAffFileToAff;
|
|
333
325
|
function parseLine(line) {
|
|
334
326
|
const result = line.match(affixLine) || ['', ''];
|
|
335
327
|
const [, option, value] = result;
|
|
336
328
|
return { option, value: value || undefined };
|
|
337
329
|
}
|
|
338
|
-
|
|
330
|
+
export const testing = {
|
|
339
331
|
parseAffixRule,
|
|
340
332
|
tablePfxOrSfx,
|
|
341
333
|
parseLine,
|
package/dist/affToDicInfo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { DictionaryInformation } from '@cspell/cspell-types';
|
|
2
|
-
import type { AffInfo } from './affDef';
|
|
2
|
+
import type { AffInfo } from './affDef.js';
|
|
3
3
|
export declare function affToDicInfo(aff: AffInfo, locale: string): DictionaryInformation;
|
|
4
4
|
//# sourceMappingURL=affToDicInfo.d.ts.map
|
package/dist/affToDicInfo.js
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const sync_1 = require("@cspell/cspell-pipe/sync");
|
|
5
|
-
const textUtils_1 = require("./textUtils");
|
|
6
|
-
function affToDicInfo(aff, locale) {
|
|
1
|
+
import { opConcatMap, opMap, pipe } from '@cspell/cspell-pipe/sync';
|
|
2
|
+
import { removeAccents, toRange } from './textUtils.js';
|
|
3
|
+
export function affToDicInfo(aff, locale) {
|
|
7
4
|
const alphabetInfo = extractAlphabet(aff, locale);
|
|
8
5
|
return {
|
|
9
6
|
...alphabetInfo,
|
|
10
7
|
...extractSuggestionEditCosts(aff, alphabetInfo),
|
|
11
8
|
locale,
|
|
12
|
-
alphabet:
|
|
13
|
-
accents:
|
|
9
|
+
alphabet: toRange(alphabetInfo.alphabet, 5),
|
|
10
|
+
accents: toRange([...alphabetInfo.accents].sort().join('')),
|
|
14
11
|
};
|
|
15
12
|
}
|
|
16
|
-
exports.affToDicInfo = affToDicInfo;
|
|
17
13
|
function extractAlphabet(aff, locale) {
|
|
18
14
|
const sources = [
|
|
19
15
|
aff.MAP,
|
|
@@ -96,7 +92,7 @@ function calcAccentForms(letters) {
|
|
|
96
92
|
return s;
|
|
97
93
|
}
|
|
98
94
|
for (const letter of letters) {
|
|
99
|
-
const base =
|
|
95
|
+
const base = removeAccents(letter);
|
|
100
96
|
const formCollection = getForm(base);
|
|
101
97
|
formCollection.add(base);
|
|
102
98
|
formCollection.add(letter);
|
|
@@ -112,9 +108,9 @@ function joinCharMap(values) {
|
|
|
112
108
|
}
|
|
113
109
|
function calcCrossAccentCapsMap(accentForms, locale) {
|
|
114
110
|
function calc(form) {
|
|
115
|
-
return new Set(
|
|
111
|
+
return new Set(pipe(form, opConcatMap((letter) => calcCapitalizationForms(letter, locale))));
|
|
116
112
|
}
|
|
117
|
-
const values =
|
|
113
|
+
const values = pipe(accentForms, opMap(calc));
|
|
118
114
|
return [...values];
|
|
119
115
|
}
|
|
120
116
|
// function addAccents(cleanLetter: string, accents: Iterable<string>, collection: Set<string>) {
|
|
@@ -129,8 +125,8 @@ function calcCrossAccentCapsMap(accentForms, locale) {
|
|
|
129
125
|
function extractFxLetters(fxm) {
|
|
130
126
|
if (!fxm)
|
|
131
127
|
return undefined;
|
|
132
|
-
const substations =
|
|
133
|
-
const partials =
|
|
128
|
+
const substations = pipe(fxm.values(), opConcatMap((f) => f.substitutionSets.values()), opConcatMap((s) => s.substitutions));
|
|
129
|
+
const partials = pipe(substations, opConcatMap((sub) => [sub.remove, sub.attach]));
|
|
134
130
|
return [...partials];
|
|
135
131
|
}
|
|
136
132
|
function* groupsOfN(values, n) {
|
package/dist/app.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const packageInfo = require('../package.json');
|
|
1
|
+
import { program } from 'commander';
|
|
2
|
+
import { readFileSync } from 'fs';
|
|
3
|
+
import { getCommand as getDictInfoCommand } from './commandDictInfo.js';
|
|
4
|
+
import { getCommand as commandWords } from './commandWords.js';
|
|
5
|
+
const pkgRaw = readFileSync(new URL('../package.json', import.meta.url), 'utf8');
|
|
6
|
+
const packageInfo = JSON.parse(pkgRaw);
|
|
8
7
|
const version = packageInfo['version'];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
program.version(version);
|
|
9
|
+
program.addCommand(commandWords());
|
|
10
|
+
program.addCommand(getDictInfoCommand());
|
|
11
|
+
program.showHelpAfterError();
|
|
12
|
+
program.parseAsync(process.argv);
|
|
14
13
|
//# sourceMappingURL=app.js.map
|
package/dist/commandDictInfo.js
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCommand = void 0;
|
|
4
1
|
// cSpell:ignore findup
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function getCommand() {
|
|
10
|
-
const commander = new
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { parseAffFile } from './affReader.js';
|
|
4
|
+
import { affToDicInfo } from './affToDicInfo.js';
|
|
5
|
+
import { escapeUnicodeCode } from './textUtils.js';
|
|
6
|
+
export function getCommand() {
|
|
7
|
+
const commander = new Command('cspell-dict-info');
|
|
11
8
|
commander
|
|
12
9
|
.arguments('<hunspell_aff_file> <locale>')
|
|
13
10
|
.description('Display the CSpell Dictionary Information')
|
|
14
11
|
.action(action);
|
|
15
12
|
return commander;
|
|
16
13
|
}
|
|
17
|
-
exports.getCommand = getCommand;
|
|
18
14
|
async function action(hunspellFile, locale) {
|
|
19
15
|
const baseFile = hunspellFile.replace(/\.(dic|aff)$/, '');
|
|
20
16
|
const affFile = baseFile + '.aff';
|
|
21
|
-
const aff = await
|
|
22
|
-
const info =
|
|
17
|
+
const aff = await parseAffFile(affFile);
|
|
18
|
+
const info = affToDicInfo(aff, locale);
|
|
23
19
|
const rawJson = JSON.stringify(info, null, 2);
|
|
24
|
-
console.log(
|
|
20
|
+
console.log(escapeUnicodeCode(rawJson));
|
|
25
21
|
}
|
|
26
22
|
//# sourceMappingURL=commandDictInfo.js.map
|
package/dist/commandWords.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCommand = void 0;
|
|
4
1
|
// cSpell:ignore findup
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { createWriteStream, openSync, writeSync } from 'fs';
|
|
4
|
+
import { genSequence } from 'gensequence';
|
|
5
|
+
import { asAffWord } from './aff.js';
|
|
6
|
+
import { IterableHunspellReader } from './IterableHunspellReader.js';
|
|
7
|
+
import { iterableToStream } from './iterableToStream.js';
|
|
8
|
+
import { batch, uniqueFilter } from './util.js';
|
|
12
9
|
const uniqueHistorySize = 500000;
|
|
13
10
|
let logStream = process.stderr;
|
|
14
|
-
function getCommand() {
|
|
15
|
-
const commander = new
|
|
11
|
+
export function getCommand() {
|
|
12
|
+
const commander = new Command('words');
|
|
16
13
|
commander
|
|
17
14
|
.arguments('<hunspell_dic_file>')
|
|
18
15
|
.option('-o, --output <file>', 'output file - defaults to stdout')
|
|
@@ -32,7 +29,6 @@ function getCommand() {
|
|
|
32
29
|
.action(action);
|
|
33
30
|
return commander;
|
|
34
31
|
}
|
|
35
|
-
exports.getCommand = getCommand;
|
|
36
32
|
function notify(message, newLine = true) {
|
|
37
33
|
message = message + (newLine ? '\n' : '');
|
|
38
34
|
logStream.write(message, 'utf-8');
|
|
@@ -52,9 +48,9 @@ function appendRules(aff) {
|
|
|
52
48
|
function writeSeqToFile(seq, outFile) {
|
|
53
49
|
return new Promise((resolve, reject) => {
|
|
54
50
|
let resolved = false;
|
|
55
|
-
const out = outFile ?
|
|
56
|
-
const bufferedSeq =
|
|
57
|
-
const dataStream =
|
|
51
|
+
const out = outFile ? createWriteStream(outFile) : process.stdout;
|
|
52
|
+
const bufferedSeq = genSequence(batch(seq, 500)).map((batch) => batch.join(''));
|
|
53
|
+
const dataStream = iterableToStream(bufferedSeq);
|
|
58
54
|
const fileStream = dataStream.pipe(out);
|
|
59
55
|
const endEvents = ['finish', 'close', 'end'];
|
|
60
56
|
function resolvePromise() {
|
|
@@ -113,7 +109,7 @@ async function actionPrime(hunspellDicFilename, options) {
|
|
|
113
109
|
log(`Dic file: ${dicFile}`);
|
|
114
110
|
log(`Aff file: ${affFile}`);
|
|
115
111
|
log(`Generating Words...`);
|
|
116
|
-
const reader = await
|
|
112
|
+
const reader = await IterableHunspellReader.createFromFiles(affFile, dicFile);
|
|
117
113
|
if (max_depth && Number.parseInt(max_depth) >= 0) {
|
|
118
114
|
reader.maxDepth = Number.parseInt(max_depth);
|
|
119
115
|
}
|
|
@@ -147,8 +143,8 @@ async function actionPrime(hunspellDicFilename, options) {
|
|
|
147
143
|
: () => {
|
|
148
144
|
/* void */
|
|
149
145
|
};
|
|
150
|
-
const seqWords = transform ? reader.seqAffWords(callback) : reader.seqRootWords().map(
|
|
151
|
-
const filterUnique = unique ?
|
|
146
|
+
const seqWords = transform ? reader.seqAffWords(callback) : reader.seqRootWords().map(asAffWord);
|
|
147
|
+
const filterUnique = unique ? uniqueFilter(uniqueHistorySize) : (_) => true;
|
|
152
148
|
const applyTransformers = (aff) => transformers.reduce((aff, fn) => fn(aff), aff);
|
|
153
149
|
const applyFilters = (aff) => filters.reduce((cur, fn) => cur && fn(aff), true);
|
|
154
150
|
const allWords = seqWords
|
|
@@ -162,8 +158,8 @@ async function actionPrime(hunspellDicFilename, options) {
|
|
|
162
158
|
if (sort) {
|
|
163
159
|
log('Sorting...');
|
|
164
160
|
const data = words.toArray().sort().join('');
|
|
165
|
-
const fd = outputFile ?
|
|
166
|
-
|
|
161
|
+
const fd = outputFile ? openSync(outputFile, 'w') : 1;
|
|
162
|
+
writeSync(fd, data);
|
|
167
163
|
}
|
|
168
164
|
else {
|
|
169
165
|
await writeSeqToFile(words, outputFile);
|
package/dist/converter.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Converter = void 0;
|
|
4
1
|
const regexSpecialCharacters = /[|\\{}()[\]^$+*?.]/g;
|
|
5
|
-
class Converter {
|
|
2
|
+
export class Converter {
|
|
6
3
|
constructor(convList) {
|
|
7
4
|
const match = convList.map(({ from }) => from.replace(regexSpecialCharacters, '\\$&')).join('|');
|
|
8
5
|
this._match = new RegExp(match, 'g');
|
|
@@ -18,5 +15,4 @@ class Converter {
|
|
|
18
15
|
});
|
|
19
16
|
}
|
|
20
17
|
}
|
|
21
|
-
exports.Converter = Converter;
|
|
22
18
|
//# sourceMappingURL=converter.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type { AffInfo, AffWord } from './affDef';
|
|
2
|
-
export { parseAff, parseAffFile as readAffFile } from './affReader';
|
|
3
|
-
export { createMatchingWordsFilter, type HunspellSrcData, IterableHunspellReader, type WordInfo, } from './IterableHunspellReader';
|
|
4
|
-
export { IterableHunspellReader as HunspellReader } from './IterableHunspellReader';
|
|
5
|
-
export { uniqueFilter } from './util';
|
|
1
|
+
export type { AffInfo, AffWord } from './affDef.js';
|
|
2
|
+
export { parseAff, parseAffFile as readAffFile } from './affReader.js';
|
|
3
|
+
export { createMatchingWordsFilter, type HunspellSrcData, IterableHunspellReader, type WordInfo, } from './IterableHunspellReader.js';
|
|
4
|
+
export { IterableHunspellReader as HunspellReader } from './IterableHunspellReader.js';
|
|
5
|
+
export { uniqueFilter } from './util.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "parseAff", { enumerable: true, get: function () { return affReader_1.parseAff; } });
|
|
6
|
-
Object.defineProperty(exports, "readAffFile", { enumerable: true, get: function () { return affReader_1.parseAffFile; } });
|
|
7
|
-
var IterableHunspellReader_1 = require("./IterableHunspellReader");
|
|
8
|
-
Object.defineProperty(exports, "createMatchingWordsFilter", { enumerable: true, get: function () { return IterableHunspellReader_1.createMatchingWordsFilter; } });
|
|
9
|
-
Object.defineProperty(exports, "IterableHunspellReader", { enumerable: true, get: function () { return IterableHunspellReader_1.IterableHunspellReader; } });
|
|
10
|
-
var IterableHunspellReader_2 = require("./IterableHunspellReader");
|
|
11
|
-
Object.defineProperty(exports, "HunspellReader", { enumerable: true, get: function () { return IterableHunspellReader_2.IterableHunspellReader; } });
|
|
12
|
-
var util_1 = require("./util");
|
|
13
|
-
Object.defineProperty(exports, "uniqueFilter", { enumerable: true, get: function () { return util_1.uniqueFilter; } });
|
|
1
|
+
export { parseAff, parseAffFile as readAffFile } from './affReader.js';
|
|
2
|
+
export { createMatchingWordsFilter, IterableHunspellReader, } from './IterableHunspellReader.js';
|
|
3
|
+
export { IterableHunspellReader as HunspellReader } from './IterableHunspellReader.js';
|
|
4
|
+
export { uniqueFilter } from './util.js';
|
|
14
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
import * as stream from 'stream';
|
|
4
4
|
export type Streamable = string | Buffer;
|
|
5
5
|
export type IterableLike<T> = Iterable<T> | IterableIterator<T>;
|
package/dist/iterableToStream.js
CHANGED
|
@@ -1,37 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.iterableToStream = void 0;
|
|
27
|
-
const stream = __importStar(require("stream"));
|
|
1
|
+
import * as stream from 'stream';
|
|
28
2
|
/**
|
|
29
3
|
* Transform an iterable into a node readable stream.
|
|
30
4
|
*/
|
|
31
|
-
function iterableToStream(src, options = { encoding: 'utf8' }) {
|
|
5
|
+
export function iterableToStream(src, options = { encoding: 'utf8' }) {
|
|
32
6
|
return new ReadableObservableStream(src, options);
|
|
33
7
|
}
|
|
34
|
-
exports.iterableToStream = iterableToStream;
|
|
35
8
|
class ReadableObservableStream extends stream.Readable {
|
|
36
9
|
constructor(_source, options) {
|
|
37
10
|
super(options);
|
|
@@ -60,5 +33,5 @@ class ReadableObservableStream extends stream.Readable {
|
|
|
60
33
|
}
|
|
61
34
|
}
|
|
62
35
|
}
|
|
63
|
-
|
|
36
|
+
export default iterableToStream;
|
|
64
37
|
//# sourceMappingURL=iterableToStream.js.map
|
package/dist/textUtils.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeLooseAccents = exports.removeAccents = exports.toRange = exports.escapeUnicodeCode = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Escape Unicode Characters
|
|
6
3
|
* @param text
|
|
7
4
|
* @param regexp
|
|
8
5
|
* @returns
|
|
9
6
|
*/
|
|
10
|
-
function escapeUnicodeCode(text, regexp = /\p{M}/gu) {
|
|
7
|
+
export function escapeUnicodeCode(text, regexp = /\p{M}/gu) {
|
|
11
8
|
return text.replace(regexp, replaceWithUnicode);
|
|
12
9
|
}
|
|
13
|
-
exports.escapeUnicodeCode = escapeUnicodeCode;
|
|
14
10
|
function replaceWithUnicode(substring) {
|
|
15
11
|
const start = 0x20;
|
|
16
12
|
const end = 0x7a;
|
|
@@ -34,7 +30,7 @@ function replaceWithUnicode(substring) {
|
|
|
34
30
|
*
|
|
35
31
|
* @param letters - sorted letters
|
|
36
32
|
*/
|
|
37
|
-
function toRange(letters, minLength = 4) {
|
|
33
|
+
export function toRange(letters, minLength = 4) {
|
|
38
34
|
const chars = [];
|
|
39
35
|
let begin = 0;
|
|
40
36
|
let end = 0;
|
|
@@ -72,13 +68,10 @@ function toRange(letters, minLength = 4) {
|
|
|
72
68
|
pushRange();
|
|
73
69
|
return chars.join('');
|
|
74
70
|
}
|
|
75
|
-
|
|
76
|
-
function removeAccents(text) {
|
|
71
|
+
export function removeAccents(text) {
|
|
77
72
|
return removeLooseAccents(text.normalize('NFD'));
|
|
78
73
|
}
|
|
79
|
-
|
|
80
|
-
function removeLooseAccents(text) {
|
|
74
|
+
export function removeLooseAccents(text) {
|
|
81
75
|
return text.replace(/\p{M}/gu, '');
|
|
82
76
|
}
|
|
83
|
-
exports.removeLooseAccents = removeLooseAccents;
|
|
84
77
|
//# sourceMappingURL=textUtils.js.map
|
package/dist/types.js
CHANGED
package/dist/util.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cleanObject = exports.isDefined = exports.filterOrderedList = exports.batch = exports.uniqueFilter = exports.hrTimeToSeconds = void 0;
|
|
4
|
-
function hrTimeToSeconds([seconds, nanoseconds]) {
|
|
1
|
+
export function hrTimeToSeconds([seconds, nanoseconds]) {
|
|
5
2
|
return seconds + nanoseconds / 1000000000;
|
|
6
3
|
}
|
|
7
|
-
|
|
8
|
-
function uniqueFilter(historySize, key = (a) => a) {
|
|
4
|
+
export function uniqueFilter(historySize, key = (a) => a) {
|
|
9
5
|
const f0 = new Set();
|
|
10
6
|
const f1 = new Set();
|
|
11
7
|
const found = [f0, f1, f0];
|
|
@@ -25,8 +21,7 @@ function uniqueFilter(historySize, key = (a) => a) {
|
|
|
25
21
|
return r;
|
|
26
22
|
};
|
|
27
23
|
}
|
|
28
|
-
|
|
29
|
-
function* batch(i, size) {
|
|
24
|
+
export function* batch(i, size) {
|
|
30
25
|
let data = [];
|
|
31
26
|
for (const t of i) {
|
|
32
27
|
data.push(t);
|
|
@@ -39,12 +34,11 @@ function* batch(i, size) {
|
|
|
39
34
|
yield data;
|
|
40
35
|
}
|
|
41
36
|
}
|
|
42
|
-
exports.batch = batch;
|
|
43
37
|
/**
|
|
44
38
|
* Generate a filter function that will remove adjacent values that compare to falsy;
|
|
45
39
|
* @param compare function to evaluate if two values are considered the same.
|
|
46
40
|
*/
|
|
47
|
-
function filterOrderedList(compare) {
|
|
41
|
+
export function filterOrderedList(compare) {
|
|
48
42
|
let last;
|
|
49
43
|
return function (t) {
|
|
50
44
|
const r = last === undefined ? last !== t : !!compare(last, t);
|
|
@@ -52,17 +46,15 @@ function filterOrderedList(compare) {
|
|
|
52
46
|
return r;
|
|
53
47
|
};
|
|
54
48
|
}
|
|
55
|
-
|
|
56
|
-
function isDefined(v) {
|
|
49
|
+
export function isDefined(v) {
|
|
57
50
|
return v !== undefined;
|
|
58
51
|
}
|
|
59
|
-
exports.isDefined = isDefined;
|
|
60
52
|
/**
|
|
61
53
|
* Remove all `undefined` values from an Object.
|
|
62
54
|
* @param obj
|
|
63
55
|
* @returns the same object.
|
|
64
56
|
*/
|
|
65
|
-
function cleanObject(obj) {
|
|
57
|
+
export function cleanObject(obj) {
|
|
66
58
|
if (typeof obj != 'object')
|
|
67
59
|
return obj;
|
|
68
60
|
const r = obj;
|
|
@@ -73,5 +65,4 @@ function cleanObject(obj) {
|
|
|
73
65
|
}
|
|
74
66
|
return obj;
|
|
75
67
|
}
|
|
76
|
-
exports.cleanObject = cleanObject;
|
|
77
68
|
//# sourceMappingURL=util.js.map
|
package/package.json
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hunspell-reader",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "A library for reading Hunspell Dictionary Files",
|
|
5
5
|
"bin": "bin.js",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
6
|
+
"type": "module",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
8
14
|
"files": [
|
|
9
15
|
"dist",
|
|
10
16
|
"bin.js",
|
|
@@ -13,14 +19,15 @@
|
|
|
13
19
|
"!**/*.test.*"
|
|
14
20
|
],
|
|
15
21
|
"scripts": {
|
|
16
|
-
"test-unit": "
|
|
22
|
+
"test-unit": "vitest run",
|
|
17
23
|
"test-spelling": "cspell \"src/**/*.ts\" \"*.md\"",
|
|
18
|
-
"smoke-test": "
|
|
24
|
+
"smoke-test": "./bin.js words ./dictionaries/nl -n 100",
|
|
19
25
|
"test": "pnpm run test-unit",
|
|
20
26
|
"build": "tsc -p .",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"coverage": "
|
|
27
|
+
"clean": "shx rm -rf dist temp coverage \"*.tsbuildInfo\"",
|
|
28
|
+
"coverage": "pnpm coverage:vitest && pnpm coverage:fix",
|
|
29
|
+
"coverage:vitest": "vitest run --coverage",
|
|
30
|
+
"coverage:fix": "nyc report --temp-dir \"$(pwd)/coverage\" --reporter lcov --report-dir \"$(pwd)/coverage\" --cwd ../..",
|
|
24
31
|
"watch": "tsc -w"
|
|
25
32
|
},
|
|
26
33
|
"repository": {
|
|
@@ -36,21 +43,15 @@
|
|
|
36
43
|
"url": "https://github.com/streetsidesoftware/cspell/issues"
|
|
37
44
|
},
|
|
38
45
|
"homepage": "https://github.com/streetsidesoftware/cspell/tree/main/packages/hunspell-reader#readme",
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"@types/jest": "^29.5.0",
|
|
41
|
-
"jest": "^29.5.0",
|
|
42
|
-
"ts-jest": "^29.1.0",
|
|
43
|
-
"typescript": "^4.9.5"
|
|
44
|
-
},
|
|
45
46
|
"dependencies": {
|
|
46
|
-
"@cspell/cspell-pipe": "^7.0.0
|
|
47
|
-
"@cspell/cspell-types": "^7.0.0
|
|
48
|
-
"commander": "^10.0.
|
|
47
|
+
"@cspell/cspell-pipe": "^7.0.0",
|
|
48
|
+
"@cspell/cspell-types": "^7.0.0",
|
|
49
|
+
"commander": "^10.0.1",
|
|
49
50
|
"gensequence": "^5.0.2",
|
|
50
51
|
"iconv-lite": "^0.6.3"
|
|
51
52
|
},
|
|
52
53
|
"engines": {
|
|
53
54
|
"node": ">=16"
|
|
54
55
|
},
|
|
55
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "52960d5ed75655978f9b633f44fd106937a63cd7"
|
|
56
57
|
}
|