From fb3f2378087f8e414f4458c8f10f1eac8f1d52f8 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Wed, 27 Dec 2023 22:33:13 +0100 Subject: [PATCH] Better types for fetchers --- src/fetchers/types.ts | 10 +++++----- src/utils/context.ts | 10 ++-------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/fetchers/types.ts b/src/fetchers/types.ts index d542298..f5dbe06 100644 --- a/src/fetchers/types.ts +++ b/src/fetchers/types.ts @@ -28,12 +28,12 @@ export type FetcherResponse = { }; // This is the version that will be inputted by library users -export type Fetcher = { - (url: string, ops: DefaultedFetcherOptions): Promise>; +export type Fetcher = { + (url: string, ops: DefaultedFetcherOptions): Promise>; }; // This is the version that scrapers will be interacting with -export type UseableFetcher = { - (url: string, ops?: FetcherOptions): Promise; - full: (url: string, ops?: FetcherOptions) => Promise>; +export type UseableFetcher = { + (url: string, ops?: FetcherOptions): Promise; + full: (url: string, ops?: FetcherOptions) => Promise>; }; diff --git a/src/utils/context.ts b/src/utils/context.ts index cf7acc7..6f16bca 100644 --- a/src/utils/context.ts +++ b/src/utils/context.ts @@ -2,14 +2,8 @@ import { MovieMedia, ShowMedia } from '@/entrypoint/utils/media'; import { UseableFetcher } from '@/fetchers/types'; export type ScrapeContext = { - proxiedFetcher: { - (...params: Parameters>): ReturnType>; - full(...params: Parameters['full']>): ReturnType['full']>; - }; - fetcher: { - (...params: Parameters>): ReturnType>; - full(...params: Parameters['full']>): ReturnType['full']>; - }; + proxiedFetcher: UseableFetcher; + fetcher: UseableFetcher; progress(val: number): void; };