I am new learner of javascript. I want to print the list of files in a directory and then print "completed" after listing all the files. Curretnly it is listing only the files in directory but not the "completed" text. I am not able to use promises properly. Can someone please help
var fs = require('fs');
f();
function f() {    
    match().then(result => console.log(result));
  } 
async function match() {
    await new Promise(resolve => {        
        return f1(resolve)
    });
    return "dir listing completed"
  }
  function f1() {
    fs.readdir("templates", (err, files) => {
        files.forEach(file => {
            console.log(file)
        })
    })   
  }
 
    