Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cspell-dictionary

Package Overview
Dependencies
Maintainers
1
Versions
123
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 6.10.0 to 6.10.1

dist/SpellingDictionary/ForbiddenWordsDictionary.d.ts

2

dist/index.d.ts

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

export { createCollection, createForbiddenWordsDictionary, createSpellingDictionary } from './SpellingDictionary';
export { createCollection, createForbiddenWordsDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, } from './SpellingDictionary';
export type { FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary';
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSpellingDictionary = exports.createForbiddenWordsDictionary = exports.createCollection = void 0;
exports.createSpellingDictionaryFromTrieFile = exports.createSpellingDictionary = exports.createForbiddenWordsDictionary = exports.createCollection = void 0;
var SpellingDictionary_1 = require("./SpellingDictionary");

@@ -8,2 +8,3 @@ Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return SpellingDictionary_1.createCollection; } });

Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createSpellingDictionary; } });
Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return SpellingDictionary_1.createSpellingDictionaryFromTrieFile; } });
//# sourceMappingURL=index.js.map
import { IterableLike } from '../util/IterableLike';
import { SpellingDictionary, SpellingDictionaryOptions, DictionaryInfo } from './SpellingDictionary';
export declare function createSpellingDictionary(wordList: readonly string[] | IterableLike<string>, name: string, source: string, options: SpellingDictionaryOptions | undefined): SpellingDictionary;
export declare function createForbiddenWordsDictionary(wordList: readonly string[], name: string, source: string, options: SpellingDictionaryOptions | undefined): SpellingDictionary;
import type { DictionaryInfo, SpellingDictionary, SpellingDictionaryOptions } from './SpellingDictionary';
export declare const defaultOptions: SpellingDictionaryOptions;
/**
* Create a SpellingDictionary
* @param wordList - list of words
* @param name - name of dictionary
* @param source - filename or uri
* @param options - dictionary options
* @returns a Spelling Dictionary
*/
export declare function createSpellingDictionary(wordList: readonly string[] | IterableLike<string>, name: string, source: string, options?: SpellingDictionaryOptions | undefined): SpellingDictionary;
export interface SpellingDictionaryLoadError extends Error {

@@ -15,4 +23,3 @@ /** The Error Name */

}
export declare function createFailedToLoadDictionary(error: SpellingDictionaryLoadError): SpellingDictionary;
export declare function createSpellingDictionaryLoadError(errorName: string, message: string, info: DictionaryInfo, cause?: Error): SpellingDictionaryLoadError;
export declare function createFailedToLoadDictionary(name: string, source: string, error: Error, options?: SpellingDictionaryOptions | undefined): SpellingDictionary;
//# sourceMappingURL=createSpellingDictionary.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSpellingDictionaryLoadError = exports.createFailedToLoadDictionary = exports.createForbiddenWordsDictionary = exports.createSpellingDictionary = void 0;
exports.createFailedToLoadDictionary = exports.createSpellingDictionary = exports.defaultOptions = void 0;
const cspell_trie_lib_1 = require("cspell-trie-lib");
const fast_equals_1 = require("fast-equals");
const gensequence_1 = require("gensequence");
const simpleCache_1 = require("../util/simpleCache");
const SpellingDictionaryFromTrie_1 = require("./SpellingDictionaryFromTrie");
const SpellingDictionaryMethods_1 = require("./SpellingDictionaryMethods");
const defaultOptions = Object.freeze({
exports.defaultOptions = Object.freeze({
weightMap: undefined,

@@ -16,2 +15,10 @@ });

const cachedParamsByWordList = new simpleCache_1.SimpleCache(64);
/**
* Create a SpellingDictionary
* @param wordList - list of words
* @param name - name of dictionary
* @param source - filename or uri
* @param options - dictionary options
* @returns a Spelling Dictionary
*/
function createSpellingDictionary(wordList, name, source, options) {

@@ -41,3 +48,3 @@ const params = [wordList, name, source, options];

const trie = (0, cspell_trie_lib_1.buildTrieFast)(words);
const opts = { ...(options || defaultOptions) };
const opts = { ...(options || exports.defaultOptions) };
if (opts.weightMap === undefined && opts.dictionaryInformation) {

@@ -48,14 +55,4 @@ opts.weightMap = (0, SpellingDictionaryMethods_1.createWeightMapFromDictionaryInformation)(opts.dictionaryInformation);

}
function createForbiddenWordsDictionary(wordList, name, source, options) {
// console.log(`createSpellingDictionary ${name} ${source}`);
const words = (0, cspell_trie_lib_1.parseDictionaryLines)(wordList.concat(wordList.map((a) => a.toLowerCase())), {
stripCaseAndAccents: !options?.noSuggest,
});
const forbidWords = gensequence_1.operators.map((w) => '!' + w)(words);
const trie = (0, cspell_trie_lib_1.buildTrieFast)(forbidWords);
return new SpellingDictionaryFromTrie_1.SpellingDictionaryFromTrie(trie, name, options || defaultOptions, source);
}
exports.createForbiddenWordsDictionary = createForbiddenWordsDictionary;
function createFailedToLoadDictionary(error) {
const { name, source, options } = error.info;
function createFailedToLoadDictionary(name, source, error, options) {
options = options || {};
return {

@@ -82,14 +79,2 @@ name,

exports.createFailedToLoadDictionary = createFailedToLoadDictionary;
function createSpellingDictionaryLoadError(errorName, message, info, cause) {
const err = {
name: errorName,
message,
info,
cause,
};
const stack = cause?.stack;
stack && (err.stack = stack);
return err;
}
exports.createSpellingDictionaryLoadError = createSpellingDictionaryLoadError;
//# sourceMappingURL=createSpellingDictionary.js.map

@@ -1,4 +0,6 @@

export { createForbiddenWordsDictionary, createSpellingDictionary } from './createSpellingDictionary';
export { createSpellingDictionary } from './createSpellingDictionary';
export { createForbiddenWordsDictionary } from './ForbiddenWordsDictionary';
export type { FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary';
export { createCollection } from './SpellingDictionaryCollection';
export { createSpellingDictionaryFromTrieFile } from './SpellingDictionaryFromTrie';
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createCollection = exports.createSpellingDictionary = exports.createForbiddenWordsDictionary = void 0;
exports.createSpellingDictionaryFromTrieFile = exports.createCollection = exports.createForbiddenWordsDictionary = exports.createSpellingDictionary = void 0;
var createSpellingDictionary_1 = require("./createSpellingDictionary");
Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return createSpellingDictionary_1.createForbiddenWordsDictionary; } });
Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return createSpellingDictionary_1.createSpellingDictionary; } });
var ForbiddenWordsDictionary_1 = require("./ForbiddenWordsDictionary");
Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return ForbiddenWordsDictionary_1.createForbiddenWordsDictionary; } });
var SpellingDictionaryCollection_1 = require("./SpellingDictionaryCollection");
Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return SpellingDictionaryCollection_1.createCollection; } });
var SpellingDictionaryFromTrie_1 = require("./SpellingDictionaryFromTrie");
Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return SpellingDictionaryFromTrie_1.createSpellingDictionaryFromTrieFile; } });
//# sourceMappingURL=index.js.map

@@ -50,3 +50,2 @@ import type { ReplaceMap, DictionaryInformation } from '@cspell/cspell-types';

repMap?: ReplaceMap;
useCompounds?: boolean;
/**

@@ -56,4 +55,10 @@ * The dictionary is case aware.

caseSensitive?: boolean;
/**
* This is a NO Suggest dictionary used for words to be ignored.
*/
noSuggest?: boolean;
weightMap?: WeightMap | undefined;
/**
* Extra dictionary information used in improving suggestions
* based upon locale.
*/
dictionaryInformation?: DictionaryInformation;

@@ -70,2 +75,11 @@ /**

supportNonStrictSearches?: boolean;
/**
* Turns on legacy word compounds.
* @deprecated
*/
useCompounds?: boolean;
/**
* Optional WeightMap used to improve suggestions.
*/
weightMap?: WeightMap | undefined;
}

@@ -72,0 +86,0 @@ export interface DictionaryInfo {

@@ -35,3 +35,11 @@ import type { SuggestionCollector, SuggestionResult } from 'cspell-trie-lib';

}
export declare function createSpellingDictionaryTrie(data: Iterable<string>, name: string, source: string, options: SpellingDictionaryOptions): SpellingDictionary;
/**
* Create a dictionary from a trie file.
* @param data - contents of a trie file.
* @param name - name of dictionary
* @param source - filename or uri
* @param options - options.
* @returns SpellingDictionary
*/
export declare function createSpellingDictionaryFromTrieFile(data: Iterable<string> | string, name: string, source: string, options: SpellingDictionaryOptions): SpellingDictionary;
//# sourceMappingURL=SpellingDictionaryFromTrie.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSpellingDictionaryTrie = exports.SpellingDictionaryFromTrie = void 0;
exports.createSpellingDictionaryFromTrieFile = exports.SpellingDictionaryFromTrie = void 0;
const cspell_trie_lib_1 = require("cspell-trie-lib");

@@ -142,3 +142,12 @@ const repMap_1 = require("../util/repMap");

SpellingDictionaryFromTrie.cachedWordsLimit = 50000;
function createSpellingDictionaryTrie(data, name, source, options) {
/**
* Create a dictionary from a trie file.
* @param data - contents of a trie file.
* @param name - name of dictionary
* @param source - filename or uri
* @param options - options.
* @returns SpellingDictionary
*/
function createSpellingDictionaryFromTrieFile(data, name, source, options) {
data = typeof data === 'string' ? data.split('\n') : data;
const trieNode = (0, cspell_trie_lib_1.importTrie)(data);

@@ -148,3 +157,3 @@ const trie = new cspell_trie_lib_1.Trie(trieNode);

}
exports.createSpellingDictionaryTrie = createSpellingDictionaryTrie;
exports.createSpellingDictionaryFromTrieFile = createSpellingDictionaryFromTrieFile;
//# sourceMappingURL=SpellingDictionaryFromTrie.js.map
{
"name": "cspell-dictionary",
"version": "6.10.0",
"version": "6.10.1",
"description": "A spelling dictionary library useful for checking words and getting suggestions.",

@@ -40,10 +40,15 @@ "main": "dist/index.js",

},
"devDependencies": {
"@types/jest": "^29.0.3",
"jest": "^29.0.3",
"ts-jest": "^29.0.1"
},
"dependencies": {
"@cspell/cspell-pipe": "^6.10.0",
"@cspell/cspell-types": "^6.10.0",
"cspell-trie-lib": "^6.10.0",
"@cspell/cspell-pipe": "^6.10.1",
"@cspell/cspell-types": "^6.10.1",
"cspell-trie-lib": "^6.10.1",
"fast-equals": "^4.0.3",
"gensequence": "^4.0.2"
},
"gitHead": "244f2ff310aa64bdb41cf93e85ba9e9f35c2b937"
"gitHead": "03625a3f7ca4ef85f3549ccae73d90d2cd3ac0f0"
}
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