Files
CommunitySolidServer/test/util/StaticAsyncHandler.ts
2020-06-05 09:51:48 +02:00

25 lines
608 B
TypeScript

import { AsyncHandler } from '../../src/util/AsyncHandler';
export class StaticAsyncHandler<TOut> extends AsyncHandler<any, TOut> {
private readonly canHandleStatic: boolean;
private readonly handleStatic: TOut;
public constructor (canHandleStatic: boolean, handleStatic: TOut) {
super();
this.canHandleStatic = canHandleStatic;
this.handleStatic = handleStatic;
}
public async canHandle (): Promise<void> {
if (this.canHandleStatic) {
return;
}
throw new Error('Not supported.');
}
public async handle (): Promise<TOut> {
return this.handleStatic;
}
}