UNPKG

website-scrap-engine

Version:
52 lines 2.66 kB
import type { Response } from 'got'; import type { Resource } from '../resource.js'; import type { AsyncResult, DownloadResource, DownloadResourceFunc, RequestOptions } from './types.js'; import type { StaticDownloadOptions } from '../options.js'; import type { PipelineExecutor } from './pipeline-executor.js'; export declare function isBytesAccepted(acceptRange?: string): boolean; export declare function isSameRangeStart(rangeStart: number, contentRange?: string): boolean; export declare function streamingDownloadToFile(res: Resource & { downloadStartTimestamp: number; }, requestOptions: RequestOptions): Promise<Response | void>; export declare function optionallySetLastModifiedTime(res: Resource, options: StaticDownloadOptions): Promise<void>; export declare function downloadStreamingResource(res: Resource, requestOptions: RequestOptions, options: StaticDownloadOptions): Promise<Resource | DownloadResource | void>; export interface StreamingBeforeDownloadHook { /** * @see PipelineExecutor.download * @see downloadStreamingResource * @see downloadStreamingResourceWithHook * @param res target resource * @param requestOptions passed to got * @param options * @param pipeline * @return processed resource, or void to discard resource */ (res: Resource, requestOptions: RequestOptions, options: StaticDownloadOptions, pipeline: PipelineExecutor): AsyncResult<DownloadResource | Resource | void>; } export interface StreamingAfterDownloadHook { /** * @see PipelineExecutor.download * @see downloadStreamingResource * @see downloadStreamingResourceWithHook * @param res target resource * @param requestOptions passed to got * @param options * @param pipeline */ (res: Resource, requestOptions: RequestOptions, options: StaticDownloadOptions, pipeline: PipelineExecutor): AsyncResult<void>; } export interface StreamingDownloadErrorHook { /** * @see PipelineExecutor.download * @see downloadStreamingResource * @see downloadStreamingResourceWithHook * @param e error * @param res target resource * @param requestOptions passed to got * @param options * @param pipeline */ (e: Error | unknown, res: Resource, requestOptions: RequestOptions, options: StaticDownloadOptions, pipeline: PipelineExecutor): AsyncResult<void>; } export declare function downloadStreamingResourceWithHook(beforeDownload?: StreamingBeforeDownloadHook, afterDownload?: StreamingAfterDownloadHook, downloadError?: StreamingDownloadErrorHook): DownloadResourceFunc; //# sourceMappingURL=download-streaming-resource.d.ts.map