smartguard/ts/index.ts

19 lines
578 B
TypeScript

import * as plugins from './smartguard.plugins.js';
import { Guard } from './smartguard.classes.guard.js';
import { GuardSet } from './smartguard.classes.guardset.js';
export * from './smartguard.classes.guard.js';
export const passGuards = async <T>(dataArg: T, guards: Array<Guard<T>>) => {
const done = plugins.smartpromise.defer();
const guardSet = new GuardSet<T>(guards);
const results = await guardSet.executeGuardsWithData(dataArg);
for (const result of results) {
if (!result) {
return;
}
}
done.resolve();
await done.promise;
return;
};