chrono-forge
Version:
A comprehensive framework for building resilient Temporal workflows, advanced state management, and real-time streaming activities in TypeScript. Designed for a seamless developer experience with powerful abstractions, dynamic orchestration, and full cont
14 lines (13 loc) • 476 B
JavaScript
;
function Guard(checkFunction) {
return (target, propertyKey, descriptor) => {
const originalMethod = descriptor.value;
descriptor.value = async function (...args) {
const canExecute = await checkFunction.apply(this, args);
if (!canExecute) {
throw new Error(`Guard check failed for method ${String(propertyKey)}`);
}
return originalMethod.apply(this, args);
};
};
}