jsdom-configurable-resource-loader
Version:
A JSDOM ResourceLoader with configuration options to whitelist and blacklist resources.
22 lines (18 loc) • 780 B
TypeScript
import { ResourceLoader, ResourceLoaderConstructorOptions, FetchOptions, AbortablePromise } from 'jsdom';
type Matcher = string | RegExp;
type NewOptions = {
whitelist: Matcher[];
} | {
blacklist: Matcher[];
} | {
whitelist: Matcher[];
blacklist: Matcher[];
};
type ConfigurableResourceLoaderOptions = ResourceLoaderConstructorOptions & NewOptions;
declare class ConfigurableResourceLoader extends ResourceLoader {
options: ConfigurableResourceLoaderOptions;
constructor(options?: ConfigurableResourceLoaderOptions);
private static strictlyResourceLoaderConstructorOptions;
fetch(url: string, options: FetchOptions): AbortablePromise<Buffer> | null;
}
export { ConfigurableResourceLoader, type ConfigurableResourceLoaderOptions, type Matcher };