createJob.js 291 B

123456789101112131415161718192021
  1. const getId = require('./utils/getId');
  2. let jobCounter = 0;
  3. module.exports = ({
  4. id: _id,
  5. action,
  6. payload = {},
  7. }) => {
  8. let id = _id;
  9. if (typeof id === 'undefined') {
  10. id = getId('Job', jobCounter);
  11. jobCounter += 1;
  12. }
  13. return {
  14. id,
  15. action,
  16. payload,
  17. };
  18. };