@readium/shared
Version:
Shared models to be used across other Readium projects and implementations in Typescript
29 lines (28 loc) • 1.11 kB
TypeScript
import { Link } from '../publication/Link';
import { Fetcher } from './Fetcher';
import { NumberRange, Resource } from './Resource';
export type FetchImplementation = (input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<Response>;
export declare class HttpFetcher implements Fetcher {
private readonly baseUrl?;
private readonly client;
constructor(client?: FetchImplementation, baseUrl?: string);
links(): Link[];
get(link: Link): Resource;
close(): void;
}
export declare class HttpResource implements Resource {
private readonly _link;
private readonly url;
private readonly client;
private _headResponse?;
constructor(client: FetchImplementation, link: Link, url: string);
/** Cached HEAD response to get the expected content length and other metadata. */
private headResponse;
close(): void;
link(): Promise<Link>;
read(range?: NumberRange): Promise<Uint8Array | undefined>;
length(): Promise<number>;
readAsJSON(): Promise<unknown>;
readAsString(): Promise<string>;
readAsXML(): Promise<XMLDocument>;
}