cspell-lib
Advanced tools
Comparing version 4.0.26 to 4.1.0
@@ -34,5 +34,5 @@ "use strict"; | ||
const languageSettings = (settings.languageSettings || []) | ||
.map(langSetting => (Object.assign({}, langSetting, { dictionaryDefinitions: DictionarySettings_1.normalizePathForDictDefs(langSetting.dictionaryDefinitions || [], pathToSettings) }))); | ||
.map(langSetting => (Object.assign(Object.assign({}, langSetting), { dictionaryDefinitions: DictionarySettings_1.normalizePathForDictDefs(langSetting.dictionaryDefinitions || [], pathToSettings) }))); | ||
const imports = typeof settings.import === 'string' ? [settings.import] : settings.import || []; | ||
const fileSettings = Object.assign({}, settings, { dictionaryDefinitions, languageSettings }); | ||
const fileSettings = Object.assign(Object.assign({}, settings), { dictionaryDefinitions, languageSettings }); | ||
if (!imports.length) { | ||
@@ -58,3 +58,3 @@ return fileSettings; | ||
cachedFiles.set(filename, finalizeSettings); // add an empty entry to prevent circular references. | ||
const settings = Object.assign({}, defaultValues, { id }, readJsonFile(filename)); | ||
const settings = Object.assign(Object.assign(Object.assign({}, defaultValues), { id }), readJsonFile(filename)); | ||
const pathToSettings = path.dirname(filename); | ||
@@ -64,3 +64,3 @@ Object.assign(finalizeSettings, normalizeSettings(settings, pathToSettings)); | ||
const name = finalizeSrc.name || path.basename(filename); | ||
finalizeSettings.source = Object.assign({}, finalizeSrc, { filename, name }); | ||
finalizeSettings.source = Object.assign(Object.assign({}, finalizeSrc), { filename, name }); | ||
cachedFiles.set(filename, finalizeSettings); | ||
@@ -122,3 +122,3 @@ return finalizeSettings; | ||
const optionals = includeRegExpList.length ? { includeRegExpList } : {}; | ||
return Object.assign({}, left, right, optionals, { id: [leftId, rightId].join('|'), name: [left.name || '', right.name || ''].join('|'), words: mergeList(left.words, right.words), userWords: mergeList(left.userWords, right.userWords), flagWords: mergeList(left.flagWords, right.flagWords), ignoreWords: mergeList(left.ignoreWords, right.ignoreWords), enabledLanguageIds: replaceIfNotEmpty(left.enabledLanguageIds, right.enabledLanguageIds), ignoreRegExpList: mergeList(left.ignoreRegExpList, right.ignoreRegExpList), patterns: mergeList(left.patterns, right.patterns), dictionaryDefinitions: mergeList(left.dictionaryDefinitions, right.dictionaryDefinitions), dictionaries: mergeList(left.dictionaries, right.dictionaries), languageSettings: mergeList(tagLanguageSettings(leftId, left.languageSettings), tagLanguageSettings(rightId, right.languageSettings)), enabled: right.enabled !== undefined ? right.enabled : left.enabled, source: mergeSources(left, right) }); | ||
return Object.assign(Object.assign(Object.assign(Object.assign({}, left), right), optionals), { id: [leftId, rightId].join('|'), name: [left.name || '', right.name || ''].join('|'), words: mergeList(left.words, right.words), userWords: mergeList(left.userWords, right.userWords), flagWords: mergeList(left.flagWords, right.flagWords), ignoreWords: mergeList(left.ignoreWords, right.ignoreWords), enabledLanguageIds: replaceIfNotEmpty(left.enabledLanguageIds, right.enabledLanguageIds), ignoreRegExpList: mergeList(left.ignoreRegExpList, right.ignoreRegExpList), patterns: mergeList(left.patterns, right.patterns), dictionaryDefinitions: mergeList(left.dictionaryDefinitions, right.dictionaryDefinitions), dictionaries: mergeList(left.dictionaries, right.dictionaries), languageSettings: mergeList(tagLanguageSettings(leftId, left.languageSettings), tagLanguageSettings(rightId, right.languageSettings)), enabled: right.enabled !== undefined ? right.enabled : left.enabled, source: mergeSources(left, right) }); | ||
} | ||
@@ -139,3 +139,3 @@ function hasLeftAncestor(s, left) { | ||
function mergeInDocSettings(left, right) { | ||
const merged = Object.assign({}, mergeSettings(left, right), { includeRegExpList: mergeList(left.includeRegExpList, right.includeRegExpList) }); | ||
const merged = Object.assign(Object.assign({}, mergeSettings(left, right)), { includeRegExpList: mergeList(left.includeRegExpList, right.includeRegExpList) }); | ||
return merged; | ||
@@ -160,3 +160,3 @@ } | ||
// apply patterns to any RegExpLists. | ||
const finalized = Object.assign({}, settings, { ignoreRegExpList: applyPatterns(settings.ignoreRegExpList, settings.patterns), includeRegExpList: applyPatterns(settings.includeRegExpList, settings.patterns) }); | ||
const finalized = Object.assign(Object.assign({}, settings), { ignoreRegExpList: applyPatterns(settings.ignoreRegExpList, settings.patterns), includeRegExpList: applyPatterns(settings.includeRegExpList, settings.patterns) }); | ||
finalized.name = 'Finalized ' + (finalized.name || ''); | ||
@@ -163,0 +163,0 @@ finalized.source = { name: settings.name || 'src', sources: [settings] }; |
@@ -22,3 +22,3 @@ "use strict"; | ||
.filter(({ name }) => dictIdSet.has(name)) | ||
.map(def => (Object.assign({}, def, { path: getFullPathName(def) }))) | ||
.map(def => (Object.assign(Object.assign({}, def), { path: getFullPathName(def) }))) | ||
// Remove any empty paths. | ||
@@ -46,5 +46,5 @@ .filter(def => !!def.path) | ||
const absPath = relPath.match(/^\./) ? path.join(defaultPath, relPath) : relPath; | ||
return Object.assign({}, def, { path: absPath.replace(/^~/, os.homedir()) }); | ||
return Object.assign(Object.assign({}, def), { path: absPath.replace(/^~/, os.homedir()) }); | ||
} | ||
exports.normalizePathForDictDef = normalizePathForDictDef; | ||
//# sourceMappingURL=DictionarySettings.js.map |
@@ -44,3 +44,3 @@ "use strict"; | ||
}) | ||
.reduce((langSetting, setting) => (Object.assign({}, SpellSettings.mergeSettings(langSetting, setting), { languageId, | ||
.reduce((langSetting, setting) => (Object.assign(Object.assign({}, SpellSettings.mergeSettings(langSetting, setting)), { languageId, | ||
local })), {}); | ||
@@ -55,3 +55,3 @@ } | ||
}; | ||
const langSettings = Object.assign({}, defaults, calcSettingsForLanguage(languageSettings, languageId, local)); | ||
const langSettings = Object.assign(Object.assign({}, defaults), calcSettingsForLanguage(languageSettings, languageId, local)); | ||
return SpellSettings.mergeSettings(settings, langSettings); | ||
@@ -58,0 +58,0 @@ } |
@@ -143,3 +143,3 @@ "use strict"; | ||
this.genSuggestions(collector, suggestOptions); | ||
return collector.suggestions.map(r => (Object.assign({}, r, { word: r.word.replace(exports.regexPrefix, '') }))); | ||
return collector.suggestions.map(r => (Object.assign(Object.assign({}, r), { word: r.word.replace(exports.regexPrefix, '') }))); | ||
} | ||
@@ -153,4 +153,4 @@ genSuggestions(collector, suggestOptions) { | ||
} | ||
exports.SpellingDictionaryFromTrie = SpellingDictionaryFromTrie; | ||
SpellingDictionaryFromTrie.cachedWordsLimit = 50000; | ||
exports.SpellingDictionaryFromTrie = SpellingDictionaryFromTrie; | ||
function impersonateCollector(collector, word) { | ||
@@ -157,0 +157,0 @@ return { |
@@ -43,3 +43,3 @@ "use strict"; | ||
this.genSuggestions(collector, suggestOptions); | ||
return collector.suggestions.map(r => (Object.assign({}, r, { word: r.word.replace(SpellingDictionary_1.regexPrefix, '') }))); | ||
return collector.suggestions.map(r => (Object.assign(Object.assign({}, r), { word: r.word.replace(SpellingDictionary_1.regexPrefix, '') }))); | ||
} | ||
@@ -46,0 +46,0 @@ get size() { |
import { Trie, WalkerIterator } from 'cspell-trie-lib'; | ||
import { SuggestionResult } from './entities'; | ||
export interface SuggestionIterator extends IterableIterator<SuggestionResult> { | ||
/** | ||
* Ask for the next result. | ||
* minValue - is used to filter out all suggestions with a matching value less than minValue | ||
*/ | ||
next: (minValue: number) => IteratorResult<SuggestionResult>; | ||
[Symbol.iterator]: () => SuggestionIterator; | ||
export interface SuggestionIterator extends Generator<SuggestionResult, any, number | undefined> { | ||
} | ||
export declare function suggest(trie: Trie, word: string, minScore?: number): SuggestionIterator; | ||
export declare function suggestIteration(i: WalkerIterator, word: string, minScore?: number): SuggestionIterator; |
@@ -38,3 +38,3 @@ "use strict"; | ||
const { minWordLength = exports.defaultMinWordLength, flagWords = [], ignoreWords = [], allowCompoundWords = false, ignoreCase = true, caseSensitive = false, } = options; | ||
const checkOptions = Object.assign({}, options, { allowCompoundWords, | ||
const checkOptions = Object.assign(Object.assign({}, options), { allowCompoundWords, | ||
ignoreCase, | ||
@@ -67,3 +67,3 @@ caseSensitive }); | ||
const isFound = isFlagged ? undefined : isWordValid(dict, word, word.line, options); | ||
return Object.assign({}, word, { isFlagged, isFound }); | ||
return Object.assign(Object.assign({}, word), { isFlagged, isFound }); | ||
} | ||
@@ -78,5 +78,5 @@ const fn = (lineSegment) => { | ||
.filter(rememberFilter(wo => wo.text.length >= minWordLength)) | ||
.map(t => (Object.assign({}, t, { line: vr.line }))) | ||
.map(t => (Object.assign(Object.assign({}, t), { line: vr.line }))) | ||
.map(wo => { | ||
const vr = Object.assign({}, wo, { text: wo.text.toLowerCase() }); | ||
const vr = Object.assign(Object.assign({}, wo), { text: wo.text.toLowerCase() }); | ||
return vr; | ||
@@ -90,3 +90,3 @@ }) | ||
// get back the original text. | ||
.map(wo => (Object.assign({}, wo, { text: Text.extractText(lineSegment, wo.offset, wo.offset + wo.text.length) }))) | ||
.map(wo => (Object.assign(Object.assign({}, wo), { text: Text.extractText(lineSegment, wo.offset, wo.offset + wo.text.length) }))) | ||
.toArray(); | ||
@@ -103,3 +103,3 @@ if (!codeWordResults.length || ignoreWordsSet.has(vr.text) || checkWord(vr, checkOptions).isFound) { | ||
.filter(rememberFilter(wo => wo.text.length >= minWordLength)) | ||
.map(wo => (Object.assign({}, wo, { line: lineSegment }))) | ||
.map(wo => (Object.assign(Object.assign({}, wo), { line: lineSegment }))) | ||
.map(checkFlagWords) | ||
@@ -106,0 +106,0 @@ .concatMap(checkFullWord); |
@@ -17,3 +17,3 @@ "use strict"; | ||
.filter(util.uniqueFn); | ||
const dictSettings = Object.assign({}, settings, { dictionaries }); | ||
const dictSettings = Object.assign(Object.assign({}, settings), { dictionaries }); | ||
const dicts = await SpellingDictionary_1.getDictionary(dictSettings); | ||
@@ -20,0 +20,0 @@ return { word, config, dicts }; |
/// <reference types="node" /> | ||
export declare function readLines(filename: string, encoding?: BufferEncoding): Promise<IterableIterator<string>>; | ||
export declare function readLines(filename: string, encoding?: BufferEncoding): Promise<Generator<string, void, undefined>>; |
import { IterableLike } from './IterableLike'; | ||
export declare function toIterableIterator<T>(i: IterableLike<T>): IterableIterator<T>; | ||
export declare function concatIterables<T>(...iterables: IterableLike<T>[]): IterableIterator<T>; | ||
export declare function toIterableIterator<T>(i: IterableLike<T>): Generator<T, void, undefined>; | ||
export declare function concatIterables<T>(...iterables: IterableLike<T>[]): Generator<T, void, undefined>; |
@@ -151,3 +151,3 @@ "use strict"; | ||
function offsetMap(offset) { | ||
return (xo) => (Object.assign({}, xo, { offset: xo.offset + offset })); | ||
return (xo) => (Object.assign(Object.assign({}, xo), { offset: xo.offset + offset })); | ||
} | ||
@@ -182,3 +182,3 @@ function stringToRegExp(pattern, defaultFlags = 'gim', forceFlags = 'g') { | ||
const [row, col] = findRowCol(wo.offset); | ||
return Object.assign({}, wo, { row, col, doc, uri }); | ||
return Object.assign(Object.assign({}, wo), { row, col, doc, uri }); | ||
}); | ||
@@ -185,0 +185,0 @@ } |
@@ -83,4 +83,4 @@ "use strict"; | ||
const sortedRanges = [ | ||
...includeRanges.map(r => (Object.assign({}, r, { type: tInclude }))), | ||
...excludeRanges.map(r => (Object.assign({}, r, { type: tExclude }))) | ||
...includeRanges.map(r => (Object.assign(Object.assign({}, r), { type: tInclude }))), | ||
...excludeRanges.map(r => (Object.assign(Object.assign({}, r), { type: tExclude }))) | ||
].sort(fnSortRanges); | ||
@@ -87,0 +87,0 @@ const result = sortedRanges.reduce((acc, range) => { |
@@ -59,4 +59,4 @@ "use strict"; | ||
const endPosError = issue.offset + issue.text.length; | ||
yield Object.assign({}, span, { text, endPos }); | ||
yield Object.assign({}, span, { isError: true, startPos: issue.offset, endPos: endPosError, text: issue.text }); | ||
yield Object.assign(Object.assign({}, span), { text, endPos }); | ||
yield Object.assign(Object.assign({}, span), { isError: true, startPos: issue.offset, endPos: endPosError, text: issue.text }); | ||
span.text = span.text.slice(endPosError - span.startPos); | ||
@@ -63,0 +63,0 @@ span.startPos = endPosError; |
@@ -9,3 +9,3 @@ export interface WordDictionary { | ||
*/ | ||
export declare function loadWordsNoError(filename: string): Promise<IterableIterator<string>>; | ||
export declare function loadWordsNoError(filename: string): Promise<Generator<string, void, undefined>>; | ||
export declare function splitLine(line: string): string[]; | ||
@@ -12,0 +12,0 @@ export declare function splitCodeWords(words: string[]): string[]; |
{ | ||
"name": "cspell-lib", | ||
"version": "4.0.26", | ||
"version": "4.1.0", | ||
"description": "A library of useful functions used across various cspell tools.", | ||
@@ -74,4 +74,4 @@ "main": "dist/index.js", | ||
"cspell-dict-scala": "^1.0.9", | ||
"cspell-io": "^4.0.17", | ||
"cspell-trie-lib": "^4.0.16", | ||
"cspell-io": "^4.0.18", | ||
"cspell-trie-lib": "^4.1.0", | ||
"cspell-util-bundle": "^4.0.5", | ||
@@ -104,5 +104,5 @@ "fs-extra": "^8.1.0", | ||
"devDependencies": { | ||
"cspell-tools": "^4.0.22" | ||
"cspell-tools": "^4.1.0" | ||
}, | ||
"gitHead": "b918b39bc90962f48043d44f7a565e8026f08118" | ||
"gitHead": "ebda8f0a8263727a73dcb3dfdf75b9f7b85e344e" | ||
} |
160700
2895
Updatedcspell-io@^4.0.18
Updatedcspell-trie-lib@^4.1.0