Ar drone node.js action order

I am working with nodejs module AR-Drone to control my parrot ar. drone 2.0. and I am using this structure.

client.takeoff();
client
    .after(5000, function() {
           		    	
	this.on('navdata', function(d) {
	if (d.demo){
	//totaly and totalx are calculated here using navdata 
			if (totaly>85){                       // if the deviation is far to the right more than 85 mm
				
					
						console.log('                          moving left ');			
						client.left(0.15);
						sleep(500).then(() => {
						client.stop();		
						});
								
				
    		}else if (totaly<-85){                // if the deviation is far to the left more than 85 mm
				
					
						console.log('                          moving right');			
						client.right(0.15);
						sleep(500).then(() => {
						client.stop();		
						});
			}else if (totalx<3000){
				
				client.front(0.02);
				sleep(250).then(() => {
						client.stop();		
						}); 
				console.log('                          moving forward');	
			}else{
				client.land();
         
			};	

};

my question is that when I write sleep(500) and then do something, does the program actualy wait 500 ms or the “if cycles” run at the same time? what is the order of the actions sent to the drone?