Skip to content

Commit c3d8b5b

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into develop
2 parents 88971e5 + 4b57dc4 commit c3d8b5b

5 files changed

Lines changed: 718 additions & 313 deletions

File tree

README.md

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,42 +1208,7 @@ const results = search(
12081208

12091209
This avoids rebuilding the index (~5-20ms) on every keystroke.
12101210

1211-
### Web Worker Offloading (Browser)
1212-
1213-
For browser apps, you can run the entire search pipeline off the main thread using the built-in Web Worker support. This keeps the UI responsive even during heavy queries.
1214-
1215-
```ts
1216-
import { createSearchWorker, supportsWorkers } from 'quran-search-engine';
1217-
1218-
// 1. Create a worker client (with automatic fallback)
1219-
const client = createSearchWorker({
1220-
// URL to the worker script — most bundlers support this pattern:
1221-
workerUrl: new URL('quran-search-engine/worker', import.meta.url),
1222-
// Optional: provide pre-loaded data for the fallback path
1223-
// (used when Workers are not available, e.g. in older browsers)
1224-
// fallbackDeps: { quranData, morphologyMap, wordMap },
1225-
});
1226-
1227-
// 2. Initialize data inside the Worker (loads quran.json, morphology, etc.)
1228-
await client.initData();
1229-
1230-
// 3. Run searches — returns a Promise<SearchResponse>
1231-
const response = await client.runSearch(
1232-
'الرحمن',
1233-
{ lemma: true, root: true, fuzzy: true, semantic: true },
1234-
{ page: 1, limit: 20 },
1235-
);
1236-
1237-
// 4. Clean up when done
1238-
client.terminate();
1239-
```
1240-
1241-
**How it works:**
1242-
1243-
- When `Worker` is available and `workerUrl` is provided, data loading and search execution happen entirely inside a dedicated Web Worker thread.
1244-
- If Worker creation fails (e.g. CSP restrictions) or the browser doesn't support Workers, the factory falls back to running search on the main thread using the provided `fallbackDeps`.
1245-
- The Worker maintains its own internal `LRUCache`, so repeated queries are fast without any extra setup.
1246-
- Use `supportsWorkers()` to check availability before constructing the client if you want explicit control.
1211+
For benchmarking, memory profiling, worker offloading, and runnable benchmark scripts, see the [Performance Guide](docs/performance.md).
12471212

12481213
**Key Differences from Unit Tests:**
12491214

0 commit comments

Comments
 (0)