Socket
Socket
Sign inDemoInstall

cspell-dictionary

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cspell-dictionary - npm Package Compare versions

Comparing version 7.0.1-alpha.0 to 7.0.1-alpha.1

dist/SpellingDictionary/SuggestOptions.d.ts

2

dist/index.d.ts
export type { CachingDictionary, FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryCollection, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary/index.js';
export { createCachingDictionary, createCollection, createFailedToLoadDictionary, createFlagWordsDictionary, createForbiddenWordsDictionary, createIgnoreWordsDictionary, createInlineSpellingDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, createSuggestDictionary, } from './SpellingDictionary/index.js';
export { createCachingDictionary, createCollection, createFailedToLoadDictionary, createFlagWordsDictionary, createForbiddenWordsDictionary, createIgnoreWordsDictionary, createInlineSpellingDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, createSuggestDictionary, createSuggestOptions, } from './SpellingDictionary/index.js';
//# sourceMappingURL=index.d.ts.map

@@ -1,1 +0,1 @@

export { createCachingDictionary, createCollection, createFailedToLoadDictionary, createFlagWordsDictionary, createForbiddenWordsDictionary, createIgnoreWordsDictionary, createInlineSpellingDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, createSuggestDictionary, } from './SpellingDictionary/index.js';
export { createCachingDictionary, createCollection, createFailedToLoadDictionary, createFlagWordsDictionary, createForbiddenWordsDictionary, createIgnoreWordsDictionary, createInlineSpellingDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, createSuggestDictionary, createSuggestOptions, } from './SpellingDictionary/index.js';

@@ -1,2 +0,2 @@

import { buildTrieFast, parseDictionaryLines } from 'cspell-trie-lib';
import { buildITrieFromWords, parseDictionaryLines } from 'cspell-trie-lib';
import { deepEqual } from 'fast-equals';

@@ -40,3 +40,3 @@ import { AutoWeakCache, SimpleCache } from '../util/simpleCache.js';

const words = parseDictionaryLines(wordList, parseOptions);
const trie = buildTrieFast(words);
const trie = buildITrieFromWords(words);
const opts = { ...(options || defaultOptions) };

@@ -43,0 +43,0 @@ if (opts.weightMap === undefined && opts.dictionaryInformation) {

import { opMap, pipe } from '@cspell/cspell-pipe/sync';
import { buildTrieFast, parseDictionaryLines } from 'cspell-trie-lib';
import { buildITrieFromWords, parseDictionaryLines } from 'cspell-trie-lib';
import { createAutoResolveWeakCache } from '../util/AutoResolve.js';

@@ -7,3 +7,2 @@ import * as Defaults from './defaults.js';

import { SpellingDictionaryFromTrie } from './SpellingDictionaryFromTrie.js';
import { suggestArgsToSuggestOptions } from './SpellingDictionaryMethods.js';
import { createTyposDictionary } from './TyposDictionary.js';

@@ -80,5 +79,3 @@ class FlagWordsDictionaryTrie extends SpellingDictionaryFromTrie {

}
suggest(...args) {
const [word] = args;
const suggestOptions = suggestArgsToSuggestOptions(args);
suggest(word, suggestOptions = {}) {
return this.dictTypos.suggest(word, suggestOptions);

@@ -124,3 +121,3 @@ }

function buildTrieDict(words, name, source) {
const trie = buildTrieFast(pipe(words, opMap((w) => '!' + w), opMap((w) => w.replace(regExpCleanIgnore, ''))));
const trie = buildITrieFromWords(pipe(words, opMap((w) => '!' + w), opMap((w) => w.replace(regExpCleanIgnore, ''))));
return new FlagWordsDictionaryTrie(trie, name, source);

@@ -127,0 +124,0 @@ }

@@ -6,7 +6,10 @@ export { CachingDictionary, createCachingDictionary } from './CachingDictionary.js';

export { createIgnoreWordsDictionary } from './IgnoreWordsDictionary.js';
export type { DictionaryDefinitionInline, FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary.js';
export type { DictionaryDefinitionInline, FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryOptions, } from './SpellingDictionary.js';
export { createCollection, SpellingDictionaryCollection } from './SpellingDictionaryCollection.js';
export { createSpellingDictionaryFromTrieFile } from './SpellingDictionaryFromTrie.js';
export { createSuggestDictionary } from './SuggestDictionary.js';
export type { SuggestOptions } from './SuggestOptions.js';
export { createSuggestOptions } from './SuggestOptions.js';
export { createTyposDictionary } from './TyposDictionary.js';
export { CompoundWordsMethod, type SuggestionCollector, type SuggestionResult } from 'cspell-trie-lib';
//# sourceMappingURL=index.d.ts.map

@@ -9,2 +9,4 @@ export { createCachingDictionary } from './CachingDictionary.js';

export { createSuggestDictionary } from './SuggestDictionary.js';
export { createSuggestOptions } from './SuggestOptions.js';
export { createTyposDictionary } from './TyposDictionary.js';
export { CompoundWordsMethod } from 'cspell-trie-lib';
import type { DictionaryInformation, ReplaceMap } from '@cspell/cspell-types';
import type { CompoundWordsMethod, SuggestionCollector, SuggestionResult, WeightMap } from 'cspell-trie-lib';
import type { SuggestionCollector, SuggestionResult, WeightMap } from 'cspell-trie-lib';
import type { SuggestOptions } from './SuggestOptions.js';
export type { DictionaryDefinitionInline } from '@cspell/cspell-types';
export { CompoundWordsMethod, type SuggestionCollector, type SuggestionResult } from 'cspell-trie-lib';
export interface SearchOptions {

@@ -17,32 +17,2 @@ /**

}
export interface SuggestOptions {
/**
* Compounding Mode.
* `NONE` is the best option.
*/
compoundMethod?: CompoundWordsMethod | undefined;
/**
* The limit on the number of suggestions to generate. If `allowTies` is true, it is possible
* for more suggestions to be generated.
*/
numSuggestions?: number | undefined;
/**
* Max number of changes / edits to the word to get to a suggestion matching suggestion.
*/
numChanges?: number | undefined;
/**
* Allow for case-ingestive checking.
*/
ignoreCase?: boolean | undefined;
/**
* If multiple suggestions have the same edit / change "cost", then included them even if
* it causes more than `numSuggestions` to be returned.
* @default false
*/
includeTies?: boolean | undefined;
/**
* Maximum amount of time to allow for generating suggestions.
*/
timeout?: number | undefined;
}
export type FindOptions = SearchOptions;

@@ -129,11 +99,2 @@ export interface Suggestion {

/**
* Generate suggestions for a word.
* @param word - word
* @param numSuggestions - max number of suggestions to generate.
* @param compoundMethod - Default NONE.
* @param numChanges - Default 5
* @param ignoreCase - true
*/
suggest(word: string, numSuggestions?: number, compoundMethod?: CompoundWordsMethod, numChanges?: number, ignoreCase?: boolean): SuggestionResult[];
/**
* Generate suggestions for a word

@@ -143,3 +104,3 @@ * @param word - word

*/
suggest(word: string, suggestOptions: SuggestOptions): SuggestionResult[];
suggest(word: string, suggestOptions?: SuggestOptions): SuggestionResult[];
getPreferredSuggestions?: (word: string) => PreferredSuggestion[];

@@ -159,4 +120,3 @@ genSuggestions(collector: SuggestionCollector, suggestOptions: SuggestOptions): void;

}
export type SuggestArgs = Parameters<SpellingDictionary['suggest']> | Parameters<(word: string, numSuggestions?: number, compoundMethod?: CompoundWordsMethod, numChanges?: number, ignoreCase?: boolean) => SuggestionResult[]>;
export declare const defaultOptions: SpellingDictionaryOptions;
//# sourceMappingURL=SpellingDictionary.d.ts.map

@@ -1,4 +0,3 @@

export { CompoundWordsMethod } from 'cspell-trie-lib';
export const defaultOptions = Object.freeze({
weightMap: undefined,
});

@@ -1,7 +0,6 @@

import { CASE_INSENSITIVE_PREFIX } from 'cspell-trie-lib';
import { CASE_INSENSITIVE_PREFIX, CompoundWordsMethod } from 'cspell-trie-lib';
import { genSequence } from 'gensequence';
import { isDefined } from '../util/util.js';
import * as Defaults from './defaults.js';
import { CompoundWordsMethod } from './SpellingDictionary.js';
import { defaultNumSuggestions, hasOptionToSearchOption, suggestArgsToSuggestOptions, suggestionCollector, } from './SpellingDictionaryMethods.js';
import { defaultNumSuggestions, hasOptionToSearchOption, suggestionCollector } from './SpellingDictionaryMethods.js';
function identityString(w) {

@@ -42,5 +41,3 @@ return w;

}
suggest(...args) {
const [word] = args;
const suggestOptions = suggestArgsToSuggestOptions(args);
suggest(word, suggestOptions = {}) {
return this._suggest(word, suggestOptions);

@@ -47,0 +44,0 @@ }

@@ -1,6 +0,7 @@

import type { SuggestionCollector, SuggestionResult } from 'cspell-trie-lib';
import { CompoundWordsMethod, Trie } from 'cspell-trie-lib';
import type { FindResult, HasOptions, SpellingDictionary, SpellingDictionaryOptions, SuggestOptions } from './SpellingDictionary.js';
/// <reference types="node" resolution-mode="require"/>
import type { ITrie, SuggestionCollector, SuggestionResult } from 'cspell-trie-lib';
import type { FindResult, HasOptions, SpellingDictionary, SpellingDictionaryOptions } from './SpellingDictionary.js';
import type { SuggestOptions } from './SuggestOptions.js';
export declare class SpellingDictionaryFromTrie implements SpellingDictionary {
readonly trie: Trie;
readonly trie: ITrie;
readonly name: string;

@@ -19,3 +20,3 @@ readonly options: SpellingDictionaryOptions;

private weightMap;
constructor(trie: Trie, name: string, options: SpellingDictionaryOptions, source?: string, size?: number);
constructor(trie: ITrie, name: string, options: SpellingDictionaryOptions, source?: string, size?: number);
get size(): number;

@@ -31,4 +32,3 @@ has(word: string, hasOptions?: HasOptions): boolean;

private _isForbidden;
suggest(word: string, numSuggestions?: number, compoundMethod?: CompoundWordsMethod, numChanges?: number, ignoreCase?: boolean): SuggestionResult[];
suggest(word: string, suggestOptions: SuggestOptions): SuggestionResult[];
suggest(word: string, suggestOptions?: SuggestOptions): SuggestionResult[];
private _suggest;

@@ -46,3 +46,3 @@ genSuggestions(collector: SuggestionCollector, suggestOptions: SuggestOptions): void;

*/
export declare function createSpellingDictionaryFromTrieFile(data: Iterable<string> | string, name: string, source: string, options: SpellingDictionaryOptions): SpellingDictionary;
export declare function createSpellingDictionaryFromTrieFile(data: string | Buffer, name: string, source: string, options: SpellingDictionaryOptions): SpellingDictionary;
declare function outerWordForms(word: string, mapWord: (word: string) => string[]): Set<string>;

@@ -49,0 +49,0 @@ export declare const __testing__: {

import { opConcatMap, pipe } from '@cspell/cspell-pipe/sync';
import { CompoundWordsMethod, importTrie, suggestionCollector, Trie } from 'cspell-trie-lib';
import { CompoundWordsMethod, decodeTrie, suggestionCollector } from 'cspell-trie-lib';
import { autoCache, createCache01 } from '../util/AutoCache.js';

@@ -7,3 +7,3 @@ import { clean } from '../util/clean.js';

import * as Defaults from './defaults.js';
import { createWeightMapFromDictionaryInformation, defaultNumSuggestions, hasOptionToSearchOption, impersonateCollector, suggestArgsToSuggestOptions, wordSearchForms, wordSuggestFormsArray, } from './SpellingDictionaryMethods.js';
import { createWeightMapFromDictionaryInformation, defaultNumSuggestions, hasOptionToSearchOption, impersonateCollector, wordSearchForms, wordSuggestFormsArray, } from './SpellingDictionaryMethods.js';
const findWordOptionsCaseSensitive = Object.freeze({ caseSensitive: true });

@@ -27,3 +27,3 @@ const findWordOptionsNotCaseSensitive = Object.freeze({ caseSensitive: false });

this.remapWord = createRepMapper(options.repMap, options.dictionaryInformation?.ignore);
this.isDictionaryCaseSensitive = options.caseSensitive ?? !trie.isLegacy;
this.isDictionaryCaseSensitive = options.caseSensitive ?? trie.isCaseAware;
this.containsNoSuggestWords = options.noSuggest || false;

@@ -107,5 +107,3 @@ this._size = size || 0;

}
suggest(...args) {
const [word] = args;
const suggestOptions = suggestArgsToSuggestOptions(args);
suggest(word, suggestOptions = {}) {
return this._suggest(word, suggestOptions);

@@ -151,5 +149,3 @@ }

export function createSpellingDictionaryFromTrieFile(data, name, source, options) {
data = typeof data === 'string' ? data.split('\n') : data;
const trieNode = importTrie(data);
const trie = new Trie(trieNode);
const trie = decodeTrie(data);
return new SpellingDictionaryFromTrie(trie, name, options, source);

@@ -156,0 +152,0 @@ }

import type { DictionaryInformation } from '@cspell/cspell-types';
import type { SuggestionResult, WeightMap } from 'cspell-trie-lib';
import type { HasOptions, SearchOptions, SuggestArgs, SuggestOptions } from './SpellingDictionary.js';
import type { HasOptions, SearchOptions } from './SpellingDictionary.js';
export { impersonateCollector, suggestionCollector } from 'cspell-trie-lib';

@@ -18,3 +18,2 @@ export type FilterSuggestionsPredicate = (word: SuggestionResult) => boolean;

export declare function canonicalSearchOptions(opt: SearchOptions): SearchOptions;
export declare function suggestArgsToSuggestOptions(args: SuggestArgs): SuggestOptions;
export declare function createWeightMapFromDictionaryInformation(di: undefined): undefined;

@@ -21,0 +20,0 @@ export declare function createWeightMapFromDictionaryInformation(di: DictionaryInformation): WeightMap;

@@ -78,14 +78,2 @@ import { mapDictionaryInformationToWeightMap } from 'cspell-trie-lib';

}
export function suggestArgsToSuggestOptions(args) {
const [_word, options, compoundMethod, numChanges, ignoreCase] = args;
const suggestOptions = typeof options === 'object'
? options
: {
numSuggestions: options,
compoundMethod,
numChanges,
ignoreCase,
};
return suggestOptions;
}
export function createWeightMapFromDictionaryInformation(di) {

@@ -92,0 +80,0 @@ return di ? mapDictionaryInformationToWeightMap(di) : undefined;

{
"name": "cspell-dictionary",
"version": "7.0.1-alpha.0",
"version": "7.0.1-alpha.1",
"description": "A spelling dictionary library useful for checking words and getting suggestions.",

@@ -50,9 +50,9 @@ "type": "module",

"dependencies": {
"@cspell/cspell-pipe": "7.0.1-alpha.0",
"@cspell/cspell-types": "7.0.1-alpha.0",
"cspell-trie-lib": "7.0.1-alpha.0",
"@cspell/cspell-pipe": "7.0.1-alpha.1",
"@cspell/cspell-types": "7.0.1-alpha.1",
"cspell-trie-lib": "7.0.1-alpha.1",
"fast-equals": "^4.0.3",
"gensequence": "^5.0.2"
},
"gitHead": "9ac874fd367a2858df9aab07fafad183347f2033"
"gitHead": "053cd11992a03203786ed64fdf9fa719eeded824"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc