remove repetition type finder

This commit is contained in:
mightypanders 2022-05-05 21:38:38 +02:00
parent 2f2817897f
commit 8e8c18b3c1
1 changed files with 0 additions and 14 deletions

View File

@ -1,14 +0,0 @@
import { CustomError, errorCodes } from "../interfaces";
import { scheduleNames, supportedSchedule } from "../types/scheduledEventTypes";
export function findInScheduleTypes(inputString: string): supportedSchedule {
const maybeScheduleName: unknown = JSON.parse(`"${inputString.toLowerCase()}"`);
const scheduleName = scheduleNames.find((validName: supportedSchedule) => validName === maybeScheduleName);
if (scheduleName) {
// `sheepName` comes from the list of `sheepNames` so the compiler is happy.
return scheduleName;
}
throw new CustomError('That is not a schedule name.', errorCodes.schedule_not_supported);
}