()
| 21 | |
| 22 | /* Convenience methods */ |
| 23 | function scheduleJob() { |
| 24 | if (arguments.length < 2) { |
| 25 | throw new RangeError('Invalid number of arguments'); |
| 26 | } |
| 27 | |
| 28 | const name = (arguments.length >= 3 && typeof arguments[0] === 'string') ? arguments[0] : null; |
| 29 | const spec = name ? arguments[1] : arguments[0]; |
| 30 | const method = name ? arguments[2] : arguments[1]; |
| 31 | const callback = name ? arguments[3] : arguments[2]; |
| 32 | |
| 33 | if (typeof method !== 'function') { |
| 34 | throw new RangeError('The job method must be a function.'); |
| 35 | } |
| 36 | |
| 37 | const job = new Job(name, method, callback); |
| 38 | |
| 39 | if (job.schedule(spec)) { |
| 40 | return job; |
| 41 | } |
| 42 | |
| 43 | return null; |
| 44 | } |
| 45 | |
| 46 | function rescheduleJob(job, spec) { |
| 47 | if (job instanceof Job) { |
no outgoing calls
no test coverage detected
searching dependent graphs…