smartguard/ts/smartguard.classes.guardset.ts

24 lines
684 B
TypeScript
Raw Normal View History

2022-03-21 20:53:46 +00:00
import * as plugins from './smartguard.plugins.js';
import { Guard } from './smartguard.classes.guard.js';
2019-08-07 14:31:53 +00:00
/**
* a guardSet is a set of guards that need to be fulfilled
*/
export class GuardSet<T> {
public guards: Array<Guard<T>>;
public passed: boolean;
constructor(guardsArrayArg: Array<Guard<T>>) {
this.guards = guardsArrayArg;
}
public async executeGuardsWithData(dataArg: T) {
const resultPromises: Array<Promise<boolean>> = [];
for (const guard of this.guards) {
const resultPromise = guard.executeGuardWithData(dataArg);
resultPromises.push(resultPromise);
}
const results = Promise.all(resultPromises);
return results;
}
2019-08-07 14:34:34 +00:00
}