cspell-dictionary
Advanced tools
Comparing version 6.24.0 to 6.25.0
export type { CachingDictionary, FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryCollection, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary'; | ||
export { createCachingDictionary, createCollection, createFailedToLoadDictionary, createFlagWordsDictionary, createForbiddenWordsDictionary, createIgnoreWordsDictionary, createInlineSpellingDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, } from './SpellingDictionary'; | ||
export { createCachingDictionary, createCollection, createFailedToLoadDictionary, createFlagWordsDictionary, createForbiddenWordsDictionary, createIgnoreWordsDictionary, createInlineSpellingDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, createSuggestDictionary, } from './SpellingDictionary'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createSpellingDictionaryFromTrieFile = exports.createSpellingDictionary = exports.createInlineSpellingDictionary = exports.createIgnoreWordsDictionary = exports.createForbiddenWordsDictionary = exports.createFlagWordsDictionary = exports.createFailedToLoadDictionary = exports.createCollection = exports.createCachingDictionary = void 0; | ||
exports.createSuggestDictionary = exports.createSpellingDictionaryFromTrieFile = exports.createSpellingDictionary = exports.createInlineSpellingDictionary = exports.createIgnoreWordsDictionary = exports.createForbiddenWordsDictionary = exports.createFlagWordsDictionary = exports.createFailedToLoadDictionary = exports.createCollection = exports.createCachingDictionary = void 0; | ||
var SpellingDictionary_1 = require("./SpellingDictionary"); | ||
@@ -14,2 +14,3 @@ Object.defineProperty(exports, "createCachingDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createCachingDictionary; } }); | ||
Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return SpellingDictionary_1.createSpellingDictionaryFromTrieFile; } }); | ||
Object.defineProperty(exports, "createSuggestDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createSuggestDictionary; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -9,4 +9,5 @@ "use strict"; | ||
const SpellingDictionaryCollection_1 = require("./SpellingDictionaryCollection"); | ||
const SuggestDictionary_1 = require("./SuggestDictionary"); | ||
function createInlineSpellingDictionary(inlineDict, source) { | ||
const { words, flagWords, ignoreWords, name } = inlineDict; | ||
const { words, flagWords, ignoreWords, suggestWords, name } = inlineDict; | ||
const dictSources = [ | ||
@@ -16,2 +17,3 @@ words && (0, createSpellingDictionary_1.createSpellingDictionary)(words, name + '-words', source, inlineDict), | ||
ignoreWords && (0, IgnoreWordsDictionary_1.createIgnoreWordsDictionary)(ignoreWords, name + '-ignore-words', source), | ||
suggestWords && (0, SuggestDictionary_1.createSuggestDictionary)(suggestWords, name + '-suggest', source), | ||
].filter(util_1.isDefined); | ||
@@ -18,0 +20,0 @@ return (0, SpellingDictionaryCollection_1.createCollection)(dictSources, name); |
@@ -9,3 +9,4 @@ export { CachingDictionary, createCachingDictionary } from './CachingDictionary'; | ||
export { createSpellingDictionaryFromTrieFile } from './SpellingDictionaryFromTrie'; | ||
export { createSuggestDictionary } from './SuggestDictionary'; | ||
export { createTyposDictionary } from './TyposDictionary'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createTyposDictionary = exports.createSpellingDictionaryFromTrieFile = exports.createCollection = exports.createIgnoreWordsDictionary = exports.createForbiddenWordsDictionary = exports.createFlagWordsDictionary = exports.createSpellingDictionary = exports.createFailedToLoadDictionary = exports.createInlineSpellingDictionary = exports.createCachingDictionary = void 0; | ||
exports.createTyposDictionary = exports.createSuggestDictionary = exports.createSpellingDictionaryFromTrieFile = exports.createCollection = exports.createIgnoreWordsDictionary = exports.createForbiddenWordsDictionary = exports.createFlagWordsDictionary = exports.createSpellingDictionary = exports.createFailedToLoadDictionary = exports.createInlineSpellingDictionary = exports.createCachingDictionary = void 0; | ||
var CachingDictionary_1 = require("./CachingDictionary"); | ||
@@ -20,4 +20,6 @@ Object.defineProperty(exports, "createCachingDictionary", { enumerable: true, get: function () { return CachingDictionary_1.createCachingDictionary; } }); | ||
Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return SpellingDictionaryFromTrie_1.createSpellingDictionaryFromTrieFile; } }); | ||
var SuggestDictionary_1 = require("./SuggestDictionary"); | ||
Object.defineProperty(exports, "createSuggestDictionary", { enumerable: true, get: function () { return SuggestDictionary_1.createSuggestDictionary; } }); | ||
var TyposDictionary_1 = require("./TyposDictionary"); | ||
Object.defineProperty(exports, "createTyposDictionary", { enumerable: true, get: function () { return TyposDictionary_1.createTyposDictionary; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -5,2 +5,19 @@ import type { TypoEntry, TyposDef } from './typos'; | ||
/** | ||
* Parse Typos Entries | ||
* | ||
* Format: | ||
* - `word:suggestion` | ||
* - `word->suggestion` | ||
* - `word: first, second, third suggestions` | ||
* | ||
* Note: | ||
* ```plaintext | ||
* yellow:blue, green | ||
* ``` | ||
* Is the same as multiple entries with the same key and different suggestions. | ||
* ```plaintext | ||
* yellow:blue | ||
* yellow:green | ||
* ``` | ||
* | ||
* Used to process entries found in a `cspell.json` file. | ||
@@ -7,0 +24,0 @@ * @param entries - entries to process |
@@ -65,2 +65,19 @@ "use strict"; | ||
/** | ||
* Parse Typos Entries | ||
* | ||
* Format: | ||
* - `word:suggestion` | ||
* - `word->suggestion` | ||
* - `word: first, second, third suggestions` | ||
* | ||
* Note: | ||
* ```plaintext | ||
* yellow:blue, green | ||
* ``` | ||
* Is the same as multiple entries with the same key and different suggestions. | ||
* ```plaintext | ||
* yellow:blue | ||
* yellow:green | ||
* ``` | ||
* | ||
* Used to process entries found in a `cspell.json` file. | ||
@@ -67,0 +84,0 @@ * @param entries - entries to process |
import type { TypoEntry, TyposDef, TyposDefKey, TyposDefValue } from './typos'; | ||
export declare function mergeDefEntry(targetDef: TyposDef, key: string, value: TyposDefValue): TyposDef; | ||
/** | ||
* Merge in place the entries `fromDef` into `targetDef` | ||
* @param targetDef - the target | ||
* @param fromDef - the source | ||
* @returns the target | ||
*/ | ||
export declare function mergeDef(targetDef: TyposDef, fromDef: TyposDef): TyposDef; | ||
/** | ||
* Append an entry to a TyposDef. | ||
@@ -4,0 +12,0 @@ * @param def - modified in place |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.extractIgnoreValues = exports.extractAllSuggestions = exports.createTyposDef = exports.appendToDef = void 0; | ||
exports.extractIgnoreValues = exports.extractAllSuggestions = exports.createTyposDef = exports.appendToDef = exports.mergeDef = exports.mergeDefEntry = void 0; | ||
const sync_1 = require("@cspell/cspell-pipe/sync"); | ||
function normalizeTyposDefValue(value) { | ||
if (!value) | ||
return false; | ||
if (typeof value === 'string') | ||
return value; | ||
const unique = [...new Set(value)]; | ||
return unique.length > 1 ? unique : unique.length === 1 ? unique[0] : false; | ||
} | ||
function mergeDefEntry(targetDef, key, value) { | ||
const curValue = targetDef[key]; | ||
if (!curValue) { | ||
targetDef[key] = normalizeTyposDefValue(value); | ||
return targetDef; | ||
} | ||
if (!value) | ||
return targetDef; | ||
const newValue = Array.isArray(curValue) ? curValue : [curValue]; | ||
if (Array.isArray(value)) { | ||
newValue.push(...value); | ||
} | ||
else { | ||
newValue.push(value); | ||
} | ||
targetDef[key] = normalizeTyposDefValue(newValue); | ||
return targetDef; | ||
} | ||
exports.mergeDefEntry = mergeDefEntry; | ||
/** | ||
* Merge in place the entries `fromDef` into `targetDef` | ||
* @param targetDef - the target | ||
* @param fromDef - the source | ||
* @returns the target | ||
*/ | ||
function mergeDef(targetDef, fromDef) { | ||
for (const key of Object.keys(fromDef)) { | ||
mergeDefEntry(targetDef, key, fromDef[key]); | ||
} | ||
return targetDef; | ||
} | ||
exports.mergeDef = mergeDef; | ||
/** | ||
* Append an entry to a TyposDef. | ||
@@ -15,3 +55,5 @@ * @param def - modified in place | ||
if (typeof entry === 'string') { | ||
def[entry] = false; | ||
if (!def[entry]) { | ||
def[entry] = false; | ||
} | ||
return def; | ||
@@ -24,7 +66,5 @@ } | ||
const s = sugs.map((s) => s.trim()).filter((s) => !!s); | ||
def[key] = !s.length ? false : s.length === 1 ? s[0] : s; | ||
return def; | ||
return mergeDefEntry(def, key, s); | ||
} | ||
Object.assign(def, entry); | ||
return def; | ||
return mergeDef(def, entry); | ||
} | ||
@@ -31,0 +71,0 @@ exports.appendToDef = appendToDef; |
{ | ||
"name": "cspell-dictionary", | ||
"version": "6.24.0", | ||
"version": "6.25.0", | ||
"description": "A spelling dictionary library useful for checking words and getting suggestions.", | ||
@@ -46,9 +46,9 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@cspell/cspell-pipe": "6.24.0", | ||
"@cspell/cspell-types": "6.24.0", | ||
"cspell-trie-lib": "6.24.0", | ||
"@cspell/cspell-pipe": "6.25.0", | ||
"@cspell/cspell-types": "6.25.0", | ||
"cspell-trie-lib": "6.25.0", | ||
"fast-equals": "^4.0.3", | ||
"gensequence": "^4.0.3" | ||
}, | ||
"gitHead": "0d1e8bf9426cd0bfb814df4f61da12d8aee57ddd" | ||
"gitHead": "fd7541605e07c43887191097d58ab58d87fac8fd" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102645
63
2420
+ Added@cspell/cspell-pipe@6.25.0(transitive)
+ Added@cspell/cspell-types@6.25.0(transitive)
+ Addedcspell-trie-lib@6.25.0(transitive)
- Removed@cspell/cspell-pipe@6.24.0(transitive)
- Removed@cspell/cspell-types@6.24.0(transitive)
- Removedcspell-trie-lib@6.24.0(transitive)
Updated@cspell/cspell-pipe@6.25.0
Updated@cspell/cspell-types@6.25.0
Updatedcspell-trie-lib@6.25.0