feat: Add delay application along with delay for action

This commit is contained in:
Faruk AYDIN
2022-12-15 01:01:30 +03:00
parent 8036d20bf9
commit 469050914b
7 changed files with 122 additions and 1 deletions

View File

@@ -0,0 +1,21 @@
export type TDelayForUnit = 'minutes' | 'hours' | 'days' | 'weeks';
const delayAsMilliseconds = (
delayForUnit: TDelayForUnit,
delayForValue: number
) => {
switch (delayForUnit) {
case 'minutes':
return delayForValue * 60 * 1000;
case 'hours':
return delayForValue * 60 * 60 * 1000;
case 'days':
return delayForValue * 24 * 60 * 60 * 1000;
case 'weeks':
return delayForValue * 7 * 24 * 60 * 60 * 1000;
default:
return 0;
}
};
export default delayAsMilliseconds;