AnyToPromise
@tsed/core
Usage
typescript
import { AnyToPromise } from "@tsed/core";Overview
ts
class AnyToPromise<T = any> {
status: AnyToPromiseStatus;
args: any[];
constructor({ hasNextFunction }?: {
hasNextFunction?: boolean;
});
isDone(): boolean;
get next(): (error?: any) => void;
call(cb: Function): Promise<AnyPromiseResult<T>>;
reject(er: any): void;
resolve(response?: any): void;
destroy(): void;
cancel(): any;
done(status: AnyToPromiseStatus): void;
handle(process: any, additionalProps?: {}): any;
protected isCanceledResponse(process: any): boolean;
}Description
Utility that normalizes various async-like values (Promise, Observable, Stream, plain value) into a single Promise-based flow with a consistent result shape.
This class is used internally to handle controller/middleware outputs, but can be reused anywhere a unified async handling is desired.
status
ts
status: AnyToPromiseStatus;args
ts
args: any[];isDone
ts
isDone(): boolean;get next
ts
get next(): (error?: any) => void;call
ts
call(cb: Function): Promise<AnyPromiseResult<T>>;reject
ts
reject(er: any): void;resolve
ts
resolve(response?: any): void;destroy
ts
destroy(): void;cancel
ts
cancel(): any;done
ts
done(status: AnyToPromiseStatus): void;handle
ts
handle(process: any, additionalProps?: {}): any;protected isCanceledResponse
ts
protected isCanceledResponse(process: any): boolean;