Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
index: number = 0;
output?: Output;
startTime: number = 0;
statusText: string = '';
stopTime: number = 0;
readonly onFail = new Event<[Error | null]>('fail');
readonly onPass = new Event<[Output]>('pass');
readonly onRun = new BailEvent<[Input]>('run');
readonly onSkip = new Event<[Input]>('skip');
readonly title: string;
private action: Action;
private status: Status = STATUS_PENDING;
// We want to support all contexts, so we use any.
// Unknown and `Context` will not work because of the constraint.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(title: string, action: Action, options?: Options) {
super(options);
if (!title || typeof title !== 'string') {
super();
if (!title || typeof title !== 'string') {
throw new Error('Tasks require a title.');
}
if (action !== null && typeof action !== 'function') {
throw new Error('Tasks require an executable function.');
}
this.action = action;
this.status = STATUS_PENDING;
this.title = title;
this.onFail = new Event('fail');
this.onPass = new Event('pass');
this.onRun = new BailEvent('run');
this.onSkip = new Event('skip');
}