UNPKG

winterspec

Version:

Write Winter-CG compatible routes with filesystem routing and tons of features

22 lines (21 loc) 757 B
/// <reference types="node" resolution-mode="require"/> import EventEmitter from "node:events"; /** * This is effectively a Promise that can be resolved multiple times in different scopes without messily holding references to the resolve function. */ export declare class AsyncWorkTracker<Result> extends EventEmitter { private state; private lastResult; /** * If work is still pending, this waits for the next work result. If work is already resolved, it returns the last result. */ waitForResult(): Promise<Result>; /** * Call this when you start async work. */ beginAsyncWork(): void; /** * Call this when the async work is done with the result. */ finishAsyncWork(result: Result): void; }