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

cspell-tools

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cspell-tools - npm Package Compare versions

Comparing version 4.1.1 to 4.1.2

10

dist/app.js

@@ -26,8 +26,11 @@ #!/usr/bin/env node

.option('-n, --no-compress', 'By default the files are Gzipped, this will turn that off.')
.option('-m, --max_depth <limit>', 'Maximum depth to apply suffix rules.')
.option('-s, --no-split', 'Treat each line as a dictionary entry, do not split')
.option('--no-sort', 'Do not sort the result')
.action(async (src, options) => {
const { max_depth } = options;
const maxDepth = max_depth !== undefined ? Number.parseInt(max_depth) : undefined;
return processAction(src, '.txt', options, async (src, dst) => {
console.log('Process "%s" to "%s"', src, dst);
await compiler_1.compileWordList(src, dst, { splitWords: options.split, sort: options.sort }).then(() => src);
await compiler_1.compileWordList(src, dst, { splitWords: options.split, sort: options.sort, maxDepth }).then(() => src);
console.log('Done "%s" to "%s"', src, dst);

@@ -41,7 +44,10 @@ return src;

.option('-o, --output <path>', 'Specify the output directory, otherwise files are written back to the same location.')
.option('-m, --max_depth <limit>', 'Maximum depth to apply suffix rules.')
.option('-n, --no-compress', 'By default the files are Gzipped, this will turn that off.')
.action((src, options) => {
const { max_depth } = options;
const maxDepth = max_depth !== undefined ? Number.parseInt(max_depth) : undefined;
return processAction(src, '.trie', options, async (src, dst) => {
console.log('Process "%s" to "%s"', src, dst);
return compiler_1.compileTrie(src, dst).then(() => src);
return compiler_1.compileTrie(src, dst, { maxDepth }).then(() => src);
});

@@ -48,0 +54,0 @@ });

7

dist/compiler/iterateWordsFromFile.d.ts
import { Sequence } from 'gensequence';
export declare function readHunspellFiles(filename: string): Promise<Sequence<string>>;
export declare function streamWordsFromFile(filename: string): Promise<Sequence<string>>;
export interface HunspellOptions {
maxDepth?: number;
}
export declare function readHunspellFiles(filename: string, options: HunspellOptions): Promise<Sequence<string>>;
export declare function streamWordsFromFile(filename: string, options: HunspellOptions): Promise<Sequence<string>>;

@@ -7,6 +7,7 @@ "use strict";

const regHunspellFile = /\.(dic|aff)$/i;
async function readHunspellFiles(filename) {
async function readHunspellFiles(filename, options) {
const dicFile = filename.replace(regHunspellFile, '.dic');
const affFile = filename.replace(regHunspellFile, '.aff');
const reader = await HR.IterableHunspellReader.createFromFiles(affFile, dicFile);
reader.maxDepth = options.maxDepth !== undefined ? options.maxDepth : reader.maxDepth;
return gensequence_1.genSequence(reader);

@@ -19,6 +20,6 @@ }

}
function streamWordsFromFile(filename) {
return regHunspellFile.test(filename) ? readHunspellFiles(filename) : iterateFile(filename);
function streamWordsFromFile(filename, options) {
return regHunspellFile.test(filename) ? readHunspellFiles(filename, options) : iterateFile(filename);
}
exports.streamWordsFromFile = streamWordsFromFile;
//# sourceMappingURL=iterateWordsFromFile.js.map
import { Sequence } from 'gensequence';
import * as Trie from 'cspell-trie-lib';
import { HunspellOptions } from './iterateWordsFromFile';
export declare function normalizeWords(lines: Sequence<string>): Sequence<string>;
export declare function lineToWords(line: string): Sequence<string>;
interface CompileWordListOptions {
interface CompileWordListOptions extends HunspellOptions {
splitWords: boolean;

@@ -10,7 +11,7 @@ sort: boolean;

export declare function compileWordList(filename: string, destFilename: string, options: CompileWordListOptions): Promise<void>;
export declare function compileWordListWithSplit(filename: string, destFilename: string): Promise<void>;
export declare function compileSimpleWordList(filename: string, destFilename: string, _options: CompileWordListOptions): Promise<void>;
export declare function compileWordListWithSplit(filename: string, destFilename: string, options?: CompileWordListOptions): Promise<void>;
export declare function compileSimpleWordList(filename: string, destFilename: string, options?: CompileWordListOptions): Promise<void>;
export declare function normalizeWordsToTrie(words: Sequence<string>): Trie.TrieNode;
export declare function compileWordListToTrieFile(words: Sequence<string>, destFilename: string): Promise<void>;
export declare function compileTrie(filename: string, destFilename: string): Promise<void>;
export declare function compileTrie(filename: string, destFilename: string, options?: HunspellOptions): Promise<void>;
export {};

@@ -6,7 +6,5 @@ "use strict";

const Text = require("./text");
const lib = require("cspell-io");
const path = require("path");
const fs_extra_1 = require("fs-extra");
const Trie = require("cspell-trie-lib");
const HR = require("hunspell-reader");
const iterateWordsFromFile_1 = require("./iterateWordsFromFile");

@@ -45,7 +43,7 @@ const fileWriter_1 = require("./fileWriter");

async function compileWordList(filename, destFilename, options) {
const getWords = () => regHunspellFile.test(filename) ? readHunspellFiles(filename) : lib.asyncIterableToArray(lib.lineReaderAsync(filename));
const pWords = iterateWordsFromFile_1.streamWordsFromFile(filename, options);
const destDir = path.dirname(destFilename);
const pDir = fs_extra_1.mkdirp(destDir);
const compile = options.splitWords ? compileWordListWithSplitSeq : compileSimpleWordListSeq;
const words = gensequence_1.genSequence(await getWords());
const words = await pWords;
const seq = compile(words)

@@ -59,8 +57,10 @@ .filter(a => !!a)

exports.compileWordList = compileWordList;
function compileWordListWithSplit(filename, destFilename) {
return compileWordList(filename, destFilename, { splitWords: true, sort: true });
function compileWordListWithSplit(filename, destFilename, options = { splitWords: true, sort: true }) {
const { sort = true } = options;
return compileWordList(filename, destFilename, Object.assign(Object.assign({}, options), { splitWords: true, sort }));
}
exports.compileWordListWithSplit = compileWordListWithSplit;
async function compileSimpleWordList(filename, destFilename, _options) {
return compileWordList(filename, destFilename, { splitWords: false, sort: true });
async function compileSimpleWordList(filename, destFilename, options = { splitWords: false, sort: true }) {
const { sort = true } = options;
return compileWordList(filename, destFilename, Object.assign(Object.assign({}, options), { splitWords: false, sort }));
}

@@ -91,11 +91,4 @@ exports.compileSimpleWordList = compileSimpleWordList;

exports.compileWordListToTrieFile = compileWordListToTrieFile;
const regHunspellFile = /\.(dic|aff)$/i;
async function readHunspellFiles(filename) {
const dicFile = filename.replace(regHunspellFile, '.dic');
const affFile = filename.replace(regHunspellFile, '.aff');
const reader = await HR.IterableHunspellReader.createFromFiles(affFile, dicFile);
return gensequence_1.genSequence(reader.iterateWords());
}
async function compileTrie(filename, destFilename) {
const words = await iterateWordsFromFile_1.streamWordsFromFile(filename);
async function compileTrie(filename, destFilename, options) {
const words = await iterateWordsFromFile_1.streamWordsFromFile(filename, options || {});
return compileWordListToTrieFile(words, destFilename);

@@ -102,0 +95,0 @@ }

{
"name": "cspell-tools",
"version": "4.1.1",
"version": "4.1.2",
"description": "Tools to assist with the development of cSpell",

@@ -48,4 +48,4 @@ "typings": "dist/index.d.ts",

"gensequence": "^2.1.3",
"glob": "^7.1.5",
"hunspell-reader": "^3.0.1",
"glob": "^7.1.6",
"hunspell-reader": "^3.1.1",
"iconv-lite": "^0.4.24",

@@ -75,3 +75,3 @@ "minimatch": "^3.0.4"

},
"gitHead": "c528fdc4f86777aefbc23a18c3ac7a51c0c9d2bd"
"gitHead": "1348f4d82dbfa469dfe25fdb082a4edbe8c3fdd7"
}
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