Basically library structure

This commit is contained in:
mrjvs
2023-08-23 20:07:39 +02:00
parent fe721bee37
commit ef766936dd
12 changed files with 191 additions and 29 deletions

View File

@@ -1,6 +1,7 @@
import { Fetcher } from '@/utils/fetcher';
import { UseableFetcher } from '@/fetchers/types';
export interface ScrapeContext {
proxiedFetcher: Fetcher;
fetcher: Fetcher;
proxiedFetcher: UseableFetcher;
fetcher: UseableFetcher;
progress(val: number): void;
}

View File

@@ -1,11 +0,0 @@
export type FetcherOptions = {
baseUrl?: string;
headers?: Record<string, string>;
query?: Record<string, string>;
method?: 'GET' | 'POST';
body?: Record<string, any> | string | FormData;
};
export type Fetcher<T = any> = {
(url: string, ops?: FetcherOptions): T;
};

7
src/utils/predicates.ts Normal file
View File

@@ -0,0 +1,7 @@
export function isNotNull<T>(value: T | null | undefined): value is T {
return value !== null && value !== undefined;
}
export function hasDuplicates<T>(values: Array<T>): boolean {
return new Set(values).size !== values.length;
}