• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

streetsidesoftware / regexp-worker / 15810503912

22 Jun 2025 08:28PM UTC coverage: 81.02% (-15.7%) from 96.703%
15810503912

Pull #975

github

web-flow
Merge 4ca3ad71e into 91a06790a
Pull Request #975: feat: Add browser support

375 of 468 branches covered (80.13%)

Branch coverage included in aggregate %.

19 of 100 new or added lines in 10 files covered. (19.0%)

6 existing lines in 1 file now uncovered.

419 of 512 relevant lines covered (81.84%)

116.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/RegExpWorkerBrowser.ts
1
import type {
2
    ExecRegExpResult,
3
    MatchAllAsRangePairsResult,
4
    MatchAllRegExpArrayResult,
5
    MatchAllRegExpResult,
6
    MatchRegExpResult,
7
} from './RegExpWorker.js';
8
import { RegExpWorkerBase } from './RegExpWorker.js';
9
import { createWorkerBrowser } from './worker/workerBrowser.js';
10

11
export { toRegExp } from './helpers/evaluateRegExp.js';
12
export type { ExecRegExpResult, MatchAllRegExpArrayResult, MatchAllRegExpResult, MatchRegExpResult, RangePair } from './RegExpWorker.js';
13

14
export class RegExpWorker extends RegExpWorkerBase {
15
    constructor(timeoutMs?: number) {
NEW
16
        super(createWorkerBrowser, timeoutMs);
×
17
    }
18
}
19

20
export function createRegExpWorker(timeoutMs?: number): RegExpWorker {
NEW
21
    return new RegExpWorker(timeoutMs);
×
22
}
23

24
/**
25
 * Run text.matchAll against a RegExp in a worker.
26
 * @param text - The text to search within.
27
 * @param regExp - The regular expression to match against the text.
28
 * @param timeLimitMs - Optional time limit in milliseconds for the operation.
29
 */
30
export async function workerMatchAll(text: string, regExp: RegExp, timeLimitMs?: number): Promise<MatchAllRegExpResult> {
NEW
31
    const worker = createRegExpWorker();
×
NEW
32
    return await worker.matchAll(text, regExp, timeLimitMs);
×
33
}
34

35
/**
36
 * Run text.matchAll against a RegExp in a worker and return the matches as [start, end] range pairs.
37
 * @param text - The text to search within.
38
 * @param regExp - The regular expression to match against the text.
39
 * @param timeLimitMs - Optional time limit in milliseconds for the operation.
40
 */
41
export async function workerMatchAllAsRangePairs(text: string, regExp: RegExp, timeLimitMs?: number): Promise<MatchAllAsRangePairsResult> {
NEW
42
    const worker = createRegExpWorker();
×
NEW
43
    return await worker.matchAllAsRangePairs(text, regExp, timeLimitMs);
×
44
}
45

46
/**
47
 * Runs text.matchAll against an array of RegExps in a worker.
48
 * @param text - The text to search within.
49
 * @param regExps - An array of regular expressions to match against the text.
50
 * @param timeLimitMs - Optional time limit in milliseconds for the operation.
51
 */
52
export async function workerMatchAllArray(text: string, regExps: RegExp[], timeLimitMs?: number): Promise<MatchAllRegExpArrayResult> {
NEW
53
    const worker = createRegExpWorker();
×
NEW
54
    return await worker.matchAllArray(text, regExps, timeLimitMs);
×
55
}
56

57
/**
58
 * Run RegExp.exec in a worker.
59
 * @param regExp - The regular expression to execute.
60
 * @param text - The text to search within.
61
 * @param timeLimitMs - Optional time limit in milliseconds for the operation.
62
 */
63
export async function workerExec(regExp: RegExp, text: string, timeLimitMs?: number): Promise<ExecRegExpResult> {
NEW
64
    const worker = createRegExpWorker();
×
NEW
65
    return await worker.exec(regExp, text, timeLimitMs);
×
66
}
67

68
/**
69
 * Run text.match with a RegExp in a worker.
70
 * @param text - The text to search within.
71
 * @param regExp - The regular expression to match against the text.
72
 * @param timeLimitMs - Optional time limit in milliseconds for the operation.
73
 */
74
export async function workerMatch(text: string, regExp: RegExp, timeLimitMs?: number): Promise<MatchRegExpResult> {
NEW
75
    const worker = createRegExpWorker();
×
NEW
76
    return await worker.match(text, regExp, timeLimitMs);
×
77
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc