Files
automatisch/packages/backend/src/helpers/delay-as-milliseconds.ts
2022-12-16 20:13:39 +01:00

26 lines
700 B
TypeScript

import Step from '../models/step';
import delayForAsMilliseconds, {
TDelayForUnit,
} from './delay-for-as-milliseconds';
import delayUntilAsMilliseconds from './delay-until-as-milliseconds';
const delayAsMilliseconds = (step: Step) => {
let delayDuration = 0;
if (step.key === 'delayFor') {
const { delayForUnit, delayForValue } = step.parameters;
delayDuration = delayForAsMilliseconds(
delayForUnit as TDelayForUnit,
Number(delayForValue)
);
} else if (step.key === 'delayUntil') {
const { delayUntil } = step.parameters;
delayDuration = delayUntilAsMilliseconds(delayUntil as string);
}
return delayDuration;
};
export default delayAsMilliseconds;