I found the answer in handler I need to add event 'onend' which will be called once parsing completes
var parser = new htmlparser.Parser({
ontext: function(text){
if(text.match(/myntra/)){
sitemapUrls.push(text);
}
},
onend: function(){
console.log(sitemapUrls.length);
}
});