functionscheduleJob() { if (arguments.length < 2) { returnnull; }
var name = (arguments.length >= 3 && typeofarguments[0] === 'string') ? arguments[0] : null; var spec = name ? arguments[1] : arguments[0]; var method = name ? arguments[2] : arguments[1]; var callback = name ? arguments[3] : arguments[2];
var job = new Job(name, method, callback);
if (job.schedule(spec)) { return job; }
returnnull; }
会先去new Job
那么就去找Job的实现方法。Job的实现方法太长了就不全贴出来了
1 2 3 4 5 6 7 8
// Make sure callback is actually a callback if (this.job === name) { // Name wasn't provided and maybe a callback is there this.callback = typeof job === 'function' ? job : false; } else { // Name was provided, and maybe a callback is there this.callback = typeof callback === 'function' ? callback : false; }