How to use nodejs’s events to realize that two events correspond to one handler?

  node.js, question

Handler’s code will only be executed when both events arrive. How will this be implemented? Thank you

var util = require("util");
 var events = require("events");
 function JobWatch(jobNameList){
 this.unfinishedJobList=jobNameList.slice(0);
 bracket
 util.inherits(JobWatch, events.EventEmitter);
 JobWatch.prototype.notifyJobDone=function(jobName){
 var jobIndex=this.unfinishedJobList[jobName];
 if(jobIndex!  ==-1){
 this.unfinishedJobList.slice(jobIndex,1);
 bracket
 if(unfinishedJobList.length===0){
 this.emit('allJobDone');
 bracket
 bracket

Create a new JobWatch instance and pass in a list of event names to be monitored.
var jobWatch=new JobWatch(jobnames);
Every time you finish your task, call the jobWatch.notifyJobDone method and pass in the event name.
jobWatch.on(“allJobDone”,function(){

//Handle your business logic

});
If the execution result data of each event needs to be passed in, it is good to modify the notifyJobDone method of jobWatch.