common.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const replacements = [
  2. ['january', '1'],
  3. ['february', '2'],
  4. ['march', '3'],
  5. ['april', '4'],
  6. ['may', '5'],
  7. ['june', '6'],
  8. ['july', '7'],
  9. ['august', '8'],
  10. ['september', '9'],
  11. ['october', '10'],
  12. ['november', '11'],
  13. ['december', '12'],
  14. ['jan', '1'],
  15. ['feb', '2'],
  16. ['mar', '3'],
  17. ['apr', '4'],
  18. ['may', '5'],
  19. ['jun', '6'],
  20. ['jul', '7'],
  21. ['aug', '8'],
  22. ['sep', '9'],
  23. ['oct', '10'],
  24. ['nov', '11'],
  25. ['dec', '12'],
  26. ['sunday', '0'],
  27. ['monday', '1'],
  28. ['tuesday', '2'],
  29. ['wednesday', '3'],
  30. ['thursday', '4'],
  31. ['friday', '5'],
  32. ['saturday', '6'],
  33. ['sun', '0'],
  34. ['mon', '1'],
  35. ['tue', '2'],
  36. ['wed', '3'],
  37. ['thu', '4'],
  38. ['fri', '5'],
  39. ['sat', '6'],
  40. ];
  41. /**
  42. * Replaces names in cron expressions
  43. */
  44. function replaceCronNames(cronExpression) {
  45. return replacements.reduce(
  46. // eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor
  47. (acc, [name, replacement]) => acc.replace(new RegExp(name, 'gi'), replacement),
  48. cronExpression,
  49. );
  50. }
  51. export { replaceCronNames };
  52. //# sourceMappingURL=common.js.map