cspell-trie-lib 8.15.3 → 8.15.5
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.
|
@@ -45,6 +45,10 @@ export interface ParseDictionaryOptions {
|
|
|
45
45
|
* Specify the separator for splitting words.
|
|
46
46
|
*/
|
|
47
47
|
splitSeparator: RegExp | string;
|
|
48
|
+
/**
|
|
49
|
+
* Do not normalize the compound character.
|
|
50
|
+
*/
|
|
51
|
+
keepOptionalCompoundCharacter: boolean;
|
|
48
52
|
}
|
|
49
53
|
export declare const defaultParseDictionaryOptions: ParseDictionaryOptions;
|
|
50
54
|
export declare const cSpellToolDirective = "cspell-dictionary:";
|
|
@@ -67,7 +71,7 @@ export declare function parseDictionaryLines(lines: Iterable<string> | string, o
|
|
|
67
71
|
export declare function parseLinesToDictionaryLegacy(lines: Iterable<string>, options?: Partial<ParseDictionaryOptions>): Trie;
|
|
68
72
|
export declare function parseDictionaryLegacy(text: string | string[], options?: Partial<ParseDictionaryOptions>): Trie;
|
|
69
73
|
export declare function parseLinesToDictionary(lines: Iterable<string>, options?: Partial<ParseDictionaryOptions>): ITrie;
|
|
70
|
-
export declare function parseDictionary(text: string | string
|
|
74
|
+
export declare function parseDictionary(text: string | Iterable<string>, options?: Partial<ParseDictionaryOptions>): ITrie;
|
|
71
75
|
declare function splitLine(line: string, regExp: RegExp | string): string[];
|
|
72
76
|
export declare const __testing__: {
|
|
73
77
|
splitLine: typeof splitLine;
|
|
@@ -17,6 +17,7 @@ const _defaultOptions = {
|
|
|
17
17
|
split: false,
|
|
18
18
|
splitKeepBoth: false,
|
|
19
19
|
splitSeparator: RegExpSplit,
|
|
20
|
+
keepOptionalCompoundCharacter: false,
|
|
20
21
|
};
|
|
21
22
|
export const defaultParseDictionaryOptions = Object.freeze(_defaultOptions);
|
|
22
23
|
export const cSpellToolDirective = 'cspell-dictionary:';
|
|
@@ -29,7 +30,7 @@ export const setOfCSpellDirectiveFlags = ['no-split', 'split', 'generate-alterna
|
|
|
29
30
|
*/
|
|
30
31
|
export function createDictionaryLineParserMapper(options) {
|
|
31
32
|
const _options = options || _defaultOptions;
|
|
32
|
-
const { commentCharacter = _defaultOptions.commentCharacter, optionalCompoundCharacter: optionalCompound = _defaultOptions.optionalCompoundCharacter, compoundCharacter: compound = _defaultOptions.compoundCharacter, caseInsensitivePrefix: ignoreCase = _defaultOptions.caseInsensitivePrefix, forbiddenPrefix: forbidden = _defaultOptions.forbiddenPrefix, keepExactPrefix: keepCase = _defaultOptions.keepExactPrefix, splitSeparator = _defaultOptions.splitSeparator, splitKeepBoth = _defaultOptions.splitKeepBoth, stripCaseAndAccentsKeepDuplicate = _defaultOptions.stripCaseAndAccentsKeepDuplicate, stripCaseAndAccentsOnForbidden = _defaultOptions.stripCaseAndAccentsOnForbidden, } = _options;
|
|
33
|
+
const { commentCharacter = _defaultOptions.commentCharacter, optionalCompoundCharacter: optionalCompound = _defaultOptions.optionalCompoundCharacter, compoundCharacter: compound = _defaultOptions.compoundCharacter, caseInsensitivePrefix: ignoreCase = _defaultOptions.caseInsensitivePrefix, forbiddenPrefix: forbidden = _defaultOptions.forbiddenPrefix, keepExactPrefix: keepCase = _defaultOptions.keepExactPrefix, splitSeparator = _defaultOptions.splitSeparator, splitKeepBoth = _defaultOptions.splitKeepBoth, stripCaseAndAccentsKeepDuplicate = _defaultOptions.stripCaseAndAccentsKeepDuplicate, stripCaseAndAccentsOnForbidden = _defaultOptions.stripCaseAndAccentsOnForbidden, keepOptionalCompoundCharacter = _defaultOptions.keepOptionalCompoundCharacter, } = _options;
|
|
33
34
|
let { stripCaseAndAccents = _defaultOptions.stripCaseAndAccents, split = _defaultOptions.split } = _options;
|
|
34
35
|
// console.log('options: %o', options);
|
|
35
36
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -141,7 +142,10 @@ export function createDictionaryLineParserMapper(options) {
|
|
|
141
142
|
yield* paragraph.split('\n');
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
|
-
const
|
|
145
|
+
const mapCompounds = keepOptionalCompoundCharacter
|
|
146
|
+
? []
|
|
147
|
+
: [opConcatMap(mapOptionalPrefix), opConcatMap(mapOptionalSuffix)];
|
|
148
|
+
const processLines = opPipe(opFilter(isString), splitLines, opMap(removeComments), splitWords, opMap(trim), opFilter(filterEmptyLines), ...mapCompounds, opConcatMap(mapNormalize), opMap(removeDoublePrefix));
|
|
145
149
|
return processLines;
|
|
146
150
|
}
|
|
147
151
|
/**
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public",
|
|
5
5
|
"provenance": true
|
|
6
6
|
},
|
|
7
|
-
"version": "8.15.
|
|
7
|
+
"version": "8.15.5",
|
|
8
8
|
"description": "Trie Data Structure to support cspell.",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"sideEffects": false,
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
},
|
|
60
60
|
"homepage": "https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-trie-lib#readme",
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@cspell/cspell-pipe": "8.15.
|
|
63
|
-
"@cspell/cspell-types": "8.15.
|
|
62
|
+
"@cspell/cspell-pipe": "8.15.5",
|
|
63
|
+
"@cspell/cspell-types": "8.15.5",
|
|
64
64
|
"gensequence": "^7.0.0"
|
|
65
65
|
},
|
|
66
66
|
"engines": {
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"@cspell/dict-nl-nl": "^2.3.3",
|
|
73
73
|
"import-meta-resolve": "^4.1.0"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "5f974b2d4d61e2582aba5a1c87fcbc127f5f06bb"
|
|
76
76
|
}
|