Refactor to worker version
This commit is contained in:
21
src/createJob.js
Normal file
21
src/createJob.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const getId = require('./utils/getId');
|
||||
|
||||
let jobCounter = 0;
|
||||
|
||||
module.exports = ({
|
||||
id: _id,
|
||||
action,
|
||||
payload = {},
|
||||
}) => {
|
||||
let id = _id;
|
||||
if (typeof id === 'undefined') {
|
||||
id = getId('Job', jobCounter);
|
||||
jobCounter += 1;
|
||||
}
|
||||
|
||||
return {
|
||||
id,
|
||||
action,
|
||||
payload,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user