Refactor: drop a few Bun.file usage

This commit is contained in:
SukkaW
2024-07-23 16:15:49 +08:00
parent e0e79c9fe5
commit 5664c38261
3 changed files with 19 additions and 12 deletions

View File

@@ -2,7 +2,9 @@ import { toASCII } from 'punycode';
import { createMemoizedPromise } from './memo-promise';
import { getPublicSuffixListTextPromise } from './download-publicsuffixlist';
const customFetch = (url: string | URL): Promise<Blob> => Promise.resolve(Bun.file(url));
const customFetch = typeof Bun !== 'undefined'
? (url: string | URL) => Promise.resolve(Bun.file(url))
: (url: string | URL) => fetch(url).then(resp => resp.blob() as Promise<Blob>);
export const getGorhillPublicSuffixPromise = createMemoizedPromise(async () => {
const [publicSuffixListDat, { default: gorhill }] = await Promise.all([