MCPcopy Create free account
hub / github.com/node-schedule/node-schedule / scheduleJob

Function scheduleJob

lib/schedule.js:23–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21
22/* Convenience methods */
23function 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
46function rescheduleJob(job, spec) {
47 if (job instanceof Job) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…