get-gorhill-publicsuffix.ts 617 B

1234567891011121314151617
  1. import { toASCII } from 'punycode';
  2. import { createMemoizedPromise } from './memo-promise';
  3. import { getPublicSuffixListTextPromise } from './download-publicsuffixlist';
  4. const customFetch = (url: string | URL): Promise<Blob> => Promise.resolve(Bun.file(url));
  5. export const getGorhillPublicSuffixPromise = createMemoizedPromise(async () => {
  6. const [publicSuffixListDat, { default: gorhill }] = await Promise.all([
  7. getPublicSuffixListTextPromise(),
  8. import('@gorhill/publicsuffixlist')
  9. ]);
  10. gorhill.parse(publicSuffixListDat, toASCII);
  11. await gorhill.enableWASM({ customFetch });
  12. return gorhill;
  13. });