Initializes the shared worker pool. Should be called by subclasses via super.initialize() or independently.
async initialize(): Promise<void> {
if (this.initialized) {
return;
}
try {
const pool = getGenericWorkerPool();
await pool.initialize();
this.initialized = true;
console.info(`[${this.getPoolName()}] Pool initialized`);
} catch (error) {
console.warn(`[${this.getPoolName()}] Failed to initialize pool:`, error);
// Still mark as initialized to use main thread fallback
this.initialized = true;
}
}
Returns initialization and availability stats.
Status object
Performs fuzzy search on manga matches using workers when available. Falls back to main thread when worker execution is not possible.
Candidate matches to search.
Search query string.
Search key definitions.
Optionaloptions: Partial<IFuseOptions<MangaMatchResult>>Optional Fuse.js configuration overrides.
Maximum number of results to return (default: 100).
Fuzzy search result with timing metadata.
async search(
matches: MangaMatchResult[],
query: string,
keys: (string | { name: string; weight?: number })[] = ["title"],
options?: Partial<IFuseOptions<MangaMatchResult>>,
maxResults: number = 100,
): Promise<FuzzySearchResult> {
const taskId = generateUniqueFuzzySearchTaskId();
await this.ensureInitialized();
return this.executeWithFallback(
() =>
this.executeOnWorker(taskId, matches, query, keys, options, maxResults),
() => this.executeOnMainThread(matches, query, keys, options, maxResults),
taskId,
);
}
Coordinates fuzzy search tasks across workers with main-thread fallback. Optimized for large dataset searches (100+ items) where Fuse.js would block the UI.
Source