mirror of
https://github.com/sussy-code/providers.git
synced 2026-03-23 03:07:46 +00:00
Better types for fetchers
This commit is contained in:
parent
c9a611d6b7
commit
fb3f237808
2 changed files with 7 additions and 13 deletions
|
|
@ -28,12 +28,12 @@ export type FetcherResponse<T = any> = {
|
|||
};
|
||||
|
||||
// This is the version that will be inputted by library users
|
||||
export type Fetcher<T = any> = {
|
||||
(url: string, ops: DefaultedFetcherOptions): Promise<FetcherResponse<T>>;
|
||||
export type Fetcher = {
|
||||
<T = any>(url: string, ops: DefaultedFetcherOptions): Promise<FetcherResponse<T>>;
|
||||
};
|
||||
|
||||
// This is the version that scrapers will be interacting with
|
||||
export type UseableFetcher<T = any> = {
|
||||
(url: string, ops?: FetcherOptions): Promise<T>;
|
||||
full: (url: string, ops?: FetcherOptions) => Promise<FetcherResponse<T>>;
|
||||
export type UseableFetcher = {
|
||||
<T = any>(url: string, ops?: FetcherOptions): Promise<T>;
|
||||
full: <T = any>(url: string, ops?: FetcherOptions) => Promise<FetcherResponse<T>>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,14 +2,8 @@ import { MovieMedia, ShowMedia } from '@/entrypoint/utils/media';
|
|||
import { UseableFetcher } from '@/fetchers/types';
|
||||
|
||||
export type ScrapeContext = {
|
||||
proxiedFetcher: {
|
||||
<T>(...params: Parameters<UseableFetcher<T>>): ReturnType<UseableFetcher<T>>;
|
||||
full<T>(...params: Parameters<UseableFetcher<T>['full']>): ReturnType<UseableFetcher<T>['full']>;
|
||||
};
|
||||
fetcher: {
|
||||
<T>(...params: Parameters<UseableFetcher<T>>): ReturnType<UseableFetcher<T>>;
|
||||
full<T>(...params: Parameters<UseableFetcher<T>['full']>): ReturnType<UseableFetcher<T>['full']>;
|
||||
};
|
||||
proxiedFetcher: UseableFetcher;
|
||||
fetcher: UseableFetcher;
|
||||
progress(val: number): void;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue