@cspell/cspell-tools 9.5.0 → 9.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin.mjs +1 -1
- package/cspell-tools.config.schema.json +29 -0
- package/dist/app.d.mts +35 -0
- package/dist/app.mjs +292 -0
- package/dist/build-OgMPaXPZ.mjs +1403 -0
- package/dist/index.d.mts +35 -0
- package/dist/index.mjs +3 -0
- package/package.json +10 -9
- package/dist/AppOptions.d.ts +0 -31
- package/dist/AppOptions.js +0 -2
- package/dist/FeatureFlags/FeatureFlags.d.ts +0 -34
- package/dist/FeatureFlags/FeatureFlags.js +0 -94
- package/dist/FeatureFlags/index.d.ts +0 -3
- package/dist/FeatureFlags/index.js +0 -3
- package/dist/FeatureFlags/parseFlags.d.ts +0 -3
- package/dist/FeatureFlags/parseFlags.js +0 -20
- package/dist/app.d.ts +0 -4
- package/dist/app.js +0 -86
- package/dist/build.d.ts +0 -12
- package/dist/build.js +0 -36
- package/dist/compile.d.ts +0 -5
- package/dist/compile.js +0 -41
- package/dist/compiler/CompileOptions.d.ts +0 -35
- package/dist/compiler/CompileOptions.js +0 -2
- package/dist/compiler/CompilerDefinitions.d.ts +0 -2
- package/dist/compiler/CompilerDefinitions.js +0 -2
- package/dist/compiler/Reader.d.ts +0 -3
- package/dist/compiler/Reader.js +0 -24
- package/dist/compiler/SourceReader.d.ts +0 -28
- package/dist/compiler/SourceReader.js +0 -44
- package/dist/compiler/WordsCollection.d.ts +0 -20
- package/dist/compiler/WordsCollection.js +0 -3
- package/dist/compiler/compile.d.ts +0 -26
- package/dist/compiler/compile.js +0 -270
- package/dist/compiler/createCompileRequest.d.ts +0 -4
- package/dist/compiler/createCompileRequest.js +0 -84
- package/dist/compiler/createWordsCollection.d.ts +0 -10
- package/dist/compiler/createWordsCollection.js +0 -111
- package/dist/compiler/index.d.ts +0 -4
- package/dist/compiler/index.js +0 -3
- package/dist/compiler/legacyLineToWords.d.ts +0 -4
- package/dist/compiler/legacyLineToWords.js +0 -20
- package/dist/compiler/logWithTimestamp.d.ts +0 -3
- package/dist/compiler/logWithTimestamp.js +0 -5
- package/dist/compiler/logger.d.ts +0 -4
- package/dist/compiler/logger.js +0 -9
- package/dist/compiler/readers/ReaderOptions.d.ts +0 -19
- package/dist/compiler/readers/ReaderOptions.js +0 -2
- package/dist/compiler/readers/readHunspellFiles.d.ts +0 -3
- package/dist/compiler/readers/readHunspellFiles.js +0 -57
- package/dist/compiler/readers/readTextFile.d.ts +0 -3
- package/dist/compiler/readers/readTextFile.js +0 -20
- package/dist/compiler/readers/regHunspellFile.d.ts +0 -2
- package/dist/compiler/readers/regHunspellFile.js +0 -2
- package/dist/compiler/readers/textFileReader.d.ts +0 -3
- package/dist/compiler/readers/textFileReader.js +0 -11
- package/dist/compiler/readers/trieFileReader.d.ts +0 -3
- package/dist/compiler/readers/trieFileReader.js +0 -16
- package/dist/compiler/splitCamelCaseIfAllowed.d.ts +0 -5
- package/dist/compiler/splitCamelCaseIfAllowed.js +0 -65
- package/dist/compiler/streamSourceWordsFromFile.d.ts +0 -3
- package/dist/compiler/streamSourceWordsFromFile.js +0 -6
- package/dist/compiler/text.d.ts +0 -10
- package/dist/compiler/text.js +0 -28
- package/dist/compiler/wordListCompiler.d.ts +0 -21
- package/dist/compiler/wordListCompiler.js +0 -205
- package/dist/compiler/wordListParser.d.ts +0 -61
- package/dist/compiler/wordListParser.js +0 -184
- package/dist/compiler/writeTextToFile.d.ts +0 -2
- package/dist/compiler/writeTextToFile.js +0 -16
- package/dist/config/config.d.ts +0 -200
- package/dist/config/config.js +0 -2
- package/dist/config/configDefaults.d.ts +0 -9
- package/dist/config/configDefaults.js +0 -9
- package/dist/config/configUtils.d.ts +0 -5
- package/dist/config/configUtils.js +0 -14
- package/dist/config/index.d.ts +0 -4
- package/dist/config/index.js +0 -3
- package/dist/config/normalizeConfig.d.ts +0 -8
- package/dist/config/normalizeConfig.js +0 -13
- package/dist/gzip/compressFiles.d.ts +0 -16
- package/dist/gzip/compressFiles.js +0 -42
- package/dist/gzip/gzip.d.ts +0 -3
- package/dist/gzip/gzip.js +0 -10
- package/dist/gzip/index.d.ts +0 -3
- package/dist/gzip/index.js +0 -3
- package/dist/shasum/checksum.d.ts +0 -7
- package/dist/shasum/checksum.js +0 -19
- package/dist/shasum/index.d.ts +0 -3
- package/dist/shasum/index.js +0 -3
- package/dist/shasum/shasum.d.ts +0 -38
- package/dist/shasum/shasum.js +0 -150
- package/dist/test/TestHelper.d.ts +0 -53
- package/dist/test/TestHelper.js +0 -121
- package/dist/test/console.d.ts +0 -9
- package/dist/test/console.js +0 -34
- package/dist/test/escapeRegEx.d.ts +0 -7
- package/dist/test/escapeRegEx.js +0 -9
- package/dist/test/normalizeOutput.d.ts +0 -3
- package/dist/test/normalizeOutput.js +0 -20
- package/dist/types.d.ts +0 -7
- package/dist/types.js +0 -2
- package/dist/util/errors.d.ts +0 -6
- package/dist/util/errors.js +0 -11
- package/dist/util/globP.d.ts +0 -7
- package/dist/util/globP.js +0 -7
- package/dist/util/index.d.ts +0 -2
- package/dist/util/index.js +0 -4
- package/dist/util/textRegex.d.ts +0 -3
- package/dist/util/textRegex.js +0 -109
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export interface TestHelper {
|
|
2
|
-
/** path to `.../cspell/package/cspell-tools/` */
|
|
3
|
-
readonly packageRoot: string;
|
|
4
|
-
/** path to `...cspell/` */
|
|
5
|
-
readonly repoRoot: string;
|
|
6
|
-
readonly tempDir: string;
|
|
7
|
-
/**
|
|
8
|
-
* delete the contents of the temp directory for the current test.
|
|
9
|
-
*/
|
|
10
|
-
clearTempDir(): void;
|
|
11
|
-
/**
|
|
12
|
-
* Resolves the parts to be an absolute path in the temp directory
|
|
13
|
-
* for a given test.
|
|
14
|
-
* @param parts
|
|
15
|
-
*/
|
|
16
|
-
resolveTemp(...parts: string[]): string;
|
|
17
|
-
createTempDir(...parts: string[]): void;
|
|
18
|
-
/**
|
|
19
|
-
* Resolves a fixture path to an absolute path
|
|
20
|
-
* @param parts - relative path to fixture
|
|
21
|
-
*/
|
|
22
|
-
resolveFixture(...parts: string[]): string;
|
|
23
|
-
/**
|
|
24
|
-
* Resolves a path to an absolute path in Samples
|
|
25
|
-
* @param parts - relative path to sample
|
|
26
|
-
*/
|
|
27
|
-
resolveSample(...parts: string[]): string;
|
|
28
|
-
/**
|
|
29
|
-
* Make the temp directory
|
|
30
|
-
* @param parts
|
|
31
|
-
*/
|
|
32
|
-
mkdir(...parts: string[]): void;
|
|
33
|
-
/**
|
|
34
|
-
* copy file
|
|
35
|
-
* @param from
|
|
36
|
-
* @param to
|
|
37
|
-
*/
|
|
38
|
-
cpFileSync(from: string, to: string): void;
|
|
39
|
-
packageTemp(...parts: string[]): string;
|
|
40
|
-
/**
|
|
41
|
-
* Signal the start of a test.
|
|
42
|
-
* Use to make test.each unique.
|
|
43
|
-
* @param name
|
|
44
|
-
*/
|
|
45
|
-
beginTest(name?: string): void;
|
|
46
|
-
getCurrentTestName(): string;
|
|
47
|
-
fileExists(path: string): Promise<boolean>;
|
|
48
|
-
}
|
|
49
|
-
export declare function createTestHelper(testFilenameUrl: string): TestHelper;
|
|
50
|
-
export declare function resolvePathToFixture(...segments: string[]): string;
|
|
51
|
-
export declare function test_dirname(importMetaUrl: string): string;
|
|
52
|
-
export declare function test_filename(importMetaUrl: string): string;
|
|
53
|
-
//# sourceMappingURL=TestHelper.d.ts.map
|
package/dist/test/TestHelper.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
|
-
import { mkdirSync, promises as fs, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import * as path from 'node:path';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { expect } from 'vitest';
|
|
6
|
-
const _dirname = test_dirname(import.meta.url);
|
|
7
|
-
const packageRoot = path.join(_dirname, '../..');
|
|
8
|
-
const repoRoot = path.join(packageRoot, '../..');
|
|
9
|
-
const tempDirBase = path.join(packageRoot, 'temp');
|
|
10
|
-
const repoSamples = path.join(repoRoot, 'packages/Samples');
|
|
11
|
-
export function createTestHelper(testFilenameUrl) {
|
|
12
|
-
testFilenameUrl && assert(testFilenameUrl.startsWith('file:'));
|
|
13
|
-
const testFilename = testFilenameUrl && test_filename(testFilenameUrl);
|
|
14
|
-
return new TestHelperImpl(testFilename || expect.getState().testPath || 'test');
|
|
15
|
-
}
|
|
16
|
-
const fixtureDir = path.join(packageRoot, 'fixtures');
|
|
17
|
-
class TestHelperImpl {
|
|
18
|
-
packageRoot = packageRoot;
|
|
19
|
-
repoRoot = repoRoot;
|
|
20
|
-
tempDir;
|
|
21
|
-
fixtureDir;
|
|
22
|
-
testCounter = new Map();
|
|
23
|
-
constructor(testFilename) {
|
|
24
|
-
this.tempDir = path.join(tempDirBase, path.relative(packageRoot, testFilename));
|
|
25
|
-
this.fixtureDir = fixtureDir;
|
|
26
|
-
}
|
|
27
|
-
beginTest() {
|
|
28
|
-
const currentTestName = this.getRawTestName();
|
|
29
|
-
const prev = this.testCounter.get(currentTestName) || 0;
|
|
30
|
-
this.testCounter.set(currentTestName, prev + 1);
|
|
31
|
-
}
|
|
32
|
-
getRawTestName() {
|
|
33
|
-
return expect.getState().currentTestName || '';
|
|
34
|
-
}
|
|
35
|
-
getCurrentTestName() {
|
|
36
|
-
const currentTestName = this.getRawTestName();
|
|
37
|
-
const counter = this.testCounter.get(currentTestName);
|
|
38
|
-
return `${currentTestName}${counter ? ' ' + counter : ''}`;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* delete the contents of the temp directory for the current test.
|
|
42
|
-
*/
|
|
43
|
-
clearTempDir() {
|
|
44
|
-
rmSync(this.resolveTemp(), { force: true, recursive: true });
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* resolve a path relative to the
|
|
48
|
-
* @param parts
|
|
49
|
-
* @returns
|
|
50
|
-
*/
|
|
51
|
-
resolveTemp(...parts) {
|
|
52
|
-
const currentTestName = this.getCurrentTestName();
|
|
53
|
-
const testName = currentTestName.replaceAll(/[^\w_.-]/g, '_');
|
|
54
|
-
return path.resolve(this.tempDir, testName, ...parts);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* make a directory. It is ok to make the same directory multiple times.
|
|
58
|
-
* @param parts
|
|
59
|
-
*/
|
|
60
|
-
mkdir(...parts) {
|
|
61
|
-
const pTemp = this.resolveTemp(...parts);
|
|
62
|
-
mkdirSync(pTemp, { recursive: true });
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Copy files from src to dest
|
|
66
|
-
* @param src - glob
|
|
67
|
-
* @param dest - directory or file
|
|
68
|
-
*/
|
|
69
|
-
cpFileSync(src, dest) {
|
|
70
|
-
const srcT = this.resolveTemp(src);
|
|
71
|
-
const dstT = this.resolveTemp(dest);
|
|
72
|
-
cpFileSync(srcT, dstT);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* resolve a path to the fixtures.
|
|
76
|
-
* @param parts
|
|
77
|
-
* @returns
|
|
78
|
-
*/
|
|
79
|
-
resolveFixture(...parts) {
|
|
80
|
-
return path.resolve(this.fixtureDir, ...parts);
|
|
81
|
-
}
|
|
82
|
-
resolveSample(...parts) {
|
|
83
|
-
return path.resolve(repoSamples, ...parts);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* calc a path relative to the package temp directory.
|
|
87
|
-
* @param parts - optional path segments
|
|
88
|
-
* @returns
|
|
89
|
-
*/
|
|
90
|
-
packageTemp(...parts) {
|
|
91
|
-
return path.resolve(tempDirBase, ...parts);
|
|
92
|
-
}
|
|
93
|
-
createTempDir = this.mkdir;
|
|
94
|
-
async fileExists(path) {
|
|
95
|
-
try {
|
|
96
|
-
await fs.stat(path);
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
catch {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
export function resolvePathToFixture(...segments) {
|
|
105
|
-
return path.resolve(fixtureDir, ...segments);
|
|
106
|
-
}
|
|
107
|
-
export function test_dirname(importMetaUrl) {
|
|
108
|
-
return fileURLToPath(new URL('.', importMetaUrl));
|
|
109
|
-
}
|
|
110
|
-
export function test_filename(importMetaUrl) {
|
|
111
|
-
return fileURLToPath(importMetaUrl);
|
|
112
|
-
}
|
|
113
|
-
function cpFileSync(srcFile, dst) {
|
|
114
|
-
const statDst = statSync(dst, { throwIfNoEntry: false });
|
|
115
|
-
if (statDst && statDst.isDirectory()) {
|
|
116
|
-
dst = path.join(dst, path.basename(srcFile));
|
|
117
|
-
}
|
|
118
|
-
const buf = readFileSync(srcFile);
|
|
119
|
-
writeFileSync(dst, buf);
|
|
120
|
-
}
|
|
121
|
-
//# sourceMappingURL=TestHelper.js.map
|
package/dist/test/console.d.ts
DELETED
package/dist/test/console.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { vi } from 'vitest';
|
|
2
|
-
import { normalizeOutput } from './normalizeOutput.js';
|
|
3
|
-
export function spyOnConsole() {
|
|
4
|
-
const con = {
|
|
5
|
-
log: vi.spyOn(console, 'log').mockImplementation(() => undefined),
|
|
6
|
-
error: vi.spyOn(console, 'error').mockImplementation(() => undefined),
|
|
7
|
-
consoleOutput,
|
|
8
|
-
attach,
|
|
9
|
-
reset,
|
|
10
|
-
};
|
|
11
|
-
function consoleOutput() {
|
|
12
|
-
const _error = con.error.mock.calls.map((c) => c.join(',')).join('\n');
|
|
13
|
-
const _log = con.log.mock.calls.map((c) => c.join(',')).join('\n');
|
|
14
|
-
return {
|
|
15
|
-
log: normalizeOutput(_log),
|
|
16
|
-
error: normalizeOutput(_error),
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function attach() {
|
|
20
|
-
reset();
|
|
21
|
-
con.log = vi.spyOn(console, 'log').mockImplementation(() => undefined);
|
|
22
|
-
con.error = vi.spyOn(console, 'error').mockImplementation(() => undefined);
|
|
23
|
-
}
|
|
24
|
-
function reset() {
|
|
25
|
-
con.log.mockRestore();
|
|
26
|
-
con.error.mockRestore();
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
consoleOutput,
|
|
30
|
-
attach,
|
|
31
|
-
reset,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=console.js.map
|
package/dist/test/escapeRegEx.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Escape a string so it can be used as an exact match within a RegExp.
|
|
3
|
-
* @param s - string to escape
|
|
4
|
-
* @returns - the escaped string.
|
|
5
|
-
*/
|
|
6
|
-
export function escapeRegEx(s) {
|
|
7
|
-
return s.replaceAll(/[|\\{}()[\]^$+*?.]/g, '\\$&').replaceAll('-', '\\x2d');
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=escapeRegEx.js.map
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as path from 'node:path';
|
|
2
|
-
import { escapeRegEx } from './escapeRegEx.js';
|
|
3
|
-
import { test_dirname } from './TestHelper.js';
|
|
4
|
-
const _dirname = test_dirname(import.meta.url);
|
|
5
|
-
const rootCspellTools = path.join(_dirname, '../..');
|
|
6
|
-
const rootRepo = path.join(rootCspellTools, '../..');
|
|
7
|
-
/**
|
|
8
|
-
* Example: `2022-10-02T17:10:04.681Z`
|
|
9
|
-
*/
|
|
10
|
-
const regexpDate = /\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?Z/gi;
|
|
11
|
-
const rxRootRepo = new RegExp(escapeRegEx(rootRepo) + '|' + escapeRegEx(normalizeDirectorySeparator(rootRepo)), 'gi');
|
|
12
|
-
export function normalizeOutput(output, cwd = process.cwd()) {
|
|
13
|
-
const rxCwd = new RegExp(escapeRegEx(cwd) + '|' + escapeRegEx(normalizeDirectorySeparator(cwd)), 'gi');
|
|
14
|
-
const normalizeDirs = normalizeDirectorySeparator(output.replace(rxCwd, '{cwd}').replace(rxRootRepo, '{repo-root}'));
|
|
15
|
-
return normalizeDirs.replaceAll(regexpDate, '2022-01-01T00:00:00.000Z');
|
|
16
|
-
}
|
|
17
|
-
export function normalizeDirectorySeparator(path) {
|
|
18
|
-
return path.replaceAll('\\', '/');
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=normalizeOutput.js.map
|
package/dist/types.d.ts
DELETED
package/dist/types.js
DELETED
package/dist/util/errors.d.ts
DELETED
package/dist/util/errors.js
DELETED
package/dist/util/globP.d.ts
DELETED
package/dist/util/globP.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { glob } from 'glob';
|
|
2
|
-
export function globP(pattern, options) {
|
|
3
|
-
// Convert windows separators.
|
|
4
|
-
const globs = (Array.isArray(pattern) ? pattern : [pattern]).map((pattern) => pattern.replaceAll('\\', '/'));
|
|
5
|
-
return glob(globs, options);
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=globP.js.map
|
package/dist/util/index.d.ts
DELETED
package/dist/util/index.js
DELETED
package/dist/util/textRegex.d.ts
DELETED
package/dist/util/textRegex.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
// cspell:ignore gimuxy
|
|
2
|
-
export const regExMatchRegExParts = /^\s*\/([\s\S]*?)\/([gimuxy]*)\s*$/;
|
|
3
|
-
export function stringToRegExp(pattern, defaultFlags = '', forceFlags = '') {
|
|
4
|
-
if (pattern instanceof RegExp) {
|
|
5
|
-
return pattern;
|
|
6
|
-
}
|
|
7
|
-
try {
|
|
8
|
-
const [, pat, flag] = [
|
|
9
|
-
...(pattern.match(regExMatchRegExParts) || ['', pattern.trim(), defaultFlags]),
|
|
10
|
-
forceFlags,
|
|
11
|
-
];
|
|
12
|
-
if (pat) {
|
|
13
|
-
const regPattern = flag.includes('x') ? removeVerboseFromRegExp(pat) : pat;
|
|
14
|
-
// Make sure the flags are unique.
|
|
15
|
-
const flags = [...new Set(forceFlags + flag)].join('').replaceAll(/[^gimuy]/g, '');
|
|
16
|
-
const regex = new RegExp(regPattern, flags);
|
|
17
|
-
return regex;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
/* empty */
|
|
22
|
-
}
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
const SPACES = {
|
|
26
|
-
' ': true,
|
|
27
|
-
'\n': true,
|
|
28
|
-
'\r': true,
|
|
29
|
-
'\t': true,
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Remove all whitespace and comments from a regexp string. The format follows Pythons Verbose.
|
|
33
|
-
* Note: this is a best attempt. Special cases for comments: `#` and spaces should be proceeded with a `\`
|
|
34
|
-
*
|
|
35
|
-
* All space must be proceeded by a `\` or in a character class `[]`
|
|
36
|
-
*
|
|
37
|
-
* @param pattern - the pattern to clean
|
|
38
|
-
*/
|
|
39
|
-
function removeVerboseFromRegExp(pattern) {
|
|
40
|
-
function escape(acc) {
|
|
41
|
-
const char = pattern[acc.idx];
|
|
42
|
-
if (char !== '\\')
|
|
43
|
-
return undefined;
|
|
44
|
-
const next = pattern[++acc.idx];
|
|
45
|
-
acc.idx++;
|
|
46
|
-
if (next === '#') {
|
|
47
|
-
acc.result += '#';
|
|
48
|
-
return acc;
|
|
49
|
-
}
|
|
50
|
-
if (!(next in SPACES)) {
|
|
51
|
-
acc.result += '\\' + next;
|
|
52
|
-
return acc;
|
|
53
|
-
}
|
|
54
|
-
acc.result += next;
|
|
55
|
-
if (next === '\r' && pattern[acc.idx] === '\n') {
|
|
56
|
-
acc.result += '\n';
|
|
57
|
-
acc.idx++;
|
|
58
|
-
}
|
|
59
|
-
return acc;
|
|
60
|
-
}
|
|
61
|
-
function braces(acc) {
|
|
62
|
-
const char = pattern[acc.idx];
|
|
63
|
-
if (char !== '[')
|
|
64
|
-
return undefined;
|
|
65
|
-
acc.result += char;
|
|
66
|
-
acc.idx++;
|
|
67
|
-
let escCount = 0;
|
|
68
|
-
while (acc.idx < pattern.length) {
|
|
69
|
-
const char = pattern[acc.idx];
|
|
70
|
-
acc.result += char;
|
|
71
|
-
acc.idx++;
|
|
72
|
-
if (char === ']' && !(escCount & 1))
|
|
73
|
-
break;
|
|
74
|
-
escCount = char === '\\' ? escCount + 1 : 0;
|
|
75
|
-
}
|
|
76
|
-
return acc;
|
|
77
|
-
}
|
|
78
|
-
function spaces(acc) {
|
|
79
|
-
const char = pattern[acc.idx];
|
|
80
|
-
if (!(char in SPACES))
|
|
81
|
-
return undefined;
|
|
82
|
-
acc.idx++;
|
|
83
|
-
return acc;
|
|
84
|
-
}
|
|
85
|
-
function comments(acc) {
|
|
86
|
-
const char = pattern[acc.idx];
|
|
87
|
-
if (char !== '#')
|
|
88
|
-
return undefined;
|
|
89
|
-
while (acc.idx < pattern.length && pattern[acc.idx] !== '\n') {
|
|
90
|
-
acc.idx++;
|
|
91
|
-
}
|
|
92
|
-
return acc;
|
|
93
|
-
}
|
|
94
|
-
function copy(acc) {
|
|
95
|
-
const char = pattern[acc.idx++];
|
|
96
|
-
acc.result += char;
|
|
97
|
-
return acc;
|
|
98
|
-
}
|
|
99
|
-
const reducers = [escape, braces, spaces, comments, copy];
|
|
100
|
-
const result = { idx: 0, result: '' };
|
|
101
|
-
while (result.idx < pattern.length) {
|
|
102
|
-
for (const r of reducers) {
|
|
103
|
-
if (r(result))
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return result.result;
|
|
108
|
-
}
|
|
109
|
-
//# sourceMappingURL=textRegex.js.map
|