You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.6 KiB
31 lines
1.6 KiB
"use strict"; |
|
Object.defineProperty(exports, "__esModule", { value: true }); |
|
exports.getDictionary = exports.refreshDictionaryCache = exports.loadDictionaries = void 0; |
|
const DictionarySettings_1 = require("../Settings/DictionarySettings"); |
|
const DictionaryLoader_1 = require("./DictionaryLoader"); |
|
const SpellingDictionary_1 = require("./SpellingDictionary"); |
|
const SpellingDictionaryCollection_1 = require("./SpellingDictionaryCollection"); |
|
function loadDictionaries(dictIds, defs) { |
|
const defsToLoad = DictionarySettings_1.filterDictDefsToLoad(dictIds, defs); |
|
return defsToLoad |
|
.map((e) => e[1]) |
|
.map((def) => DictionaryLoader_1.loadDictionary(def.path, def)) |
|
.map((p) => p.catch(() => undefined)) |
|
.filter((p) => !!p) |
|
.map((a) => a); |
|
} |
|
exports.loadDictionaries = loadDictionaries; |
|
function refreshDictionaryCache(maxAge) { |
|
return DictionaryLoader_1.refreshCacheEntries(maxAge); |
|
} |
|
exports.refreshDictionaryCache = refreshDictionaryCache; |
|
function getDictionary(settings) { |
|
const { words = [], userWords = [], dictionaries = [], dictionaryDefinitions = [], flagWords = [], caseSensitive = false, } = settings; |
|
const spellDictionaries = loadDictionaries(dictionaries, dictionaryDefinitions); |
|
const settingsDictionary = SpellingDictionary_1.createSpellingDictionary(words.concat(userWords), 'user_words', 'From Settings', { |
|
caseSensitive, |
|
}); |
|
return SpellingDictionaryCollection_1.createCollectionP([...spellDictionaries, Promise.resolve(settingsDictionary)], 'dictionary collection', flagWords); |
|
} |
|
exports.getDictionary = getDictionary; |
|
//# sourceMappingURL=Dictionaries.js.map
|