Add fetchWorker for fetching off the main thread

This commit is contained in:
Alex Gleason
2023-11-28 18:44:23 -06:00
parent 81971df7fd
commit 3a85e3f8bf
7 changed files with 56 additions and 3 deletions

14
src/workers/fetch.test.ts Normal file
View File

@@ -0,0 +1,14 @@
import { assert } from '@/deps-test.ts';
import { fetchWorker } from './fetch.ts';
Deno.test('fetchWorker', async () => {
await sleep(2000);
const response = await fetchWorker('https://example.com');
const text = await response.text();
assert(text.includes('Example Domain'));
});
function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}