import { Future } from './future'; /** * @internal */ export type ProgressInspectionResult = { state: 'pending'; progress: Progress; } | { state: 'fulfilled'; value: Result; } | { state: 'rejected'; reason: unknown; }; /** * Create a promise, but with progress reporting * * @beta * @typeParam Result - type of the progress's fulfilled value * @typeParam CurrentProgress - type of current progress used in p.report or p.progress */ export declare class Progress extends Future { /** * creates a new progress object and runs the given function with the progress as parameter, * returns the created progress object. * * the function should report progress and call `progress.resolve` / `progress.reject` once done. * * @example * ```typescript * Progress.run((progress) => { * progress.report(100) * progress.resolve('hello') * }, 0) * ``` */ static run(fn: (progress: Progress) => unknown, initialProgress: CurrentProgress): Progress; private currentProgress; private listeners; /** * create a promise, but with progress reporting. */ constructor(initialProgress: CurrentProgress); /** * get last reported progress (despite current progress state) */ get progress(): CurrentProgress; /** * inspect the current progress, for debug purpose only. */ inspect(): ProgressInspectionResult; /** * register a listener on progress report, and use the returned function to cancel listening. * * listeners won't receive messages on progress rejection */ onProgress(listener: (progress: Readonly) => unknown): () => boolean; /** * report current progress * * no-op if progress has already fulfilled or rejected */ report(progress: CurrentProgress): void; } //# sourceMappingURL=progress.d.ts.map