code: async function isFileOfType(filename, condition){
      try{
          // get stats
          const stats = await _fs.stat(filename);
  
          // is directory ?
          return condition(stats);
      }catch(e){
          // file not found error ?
          if (e.code === 'ENOENT'){
              return false;
          }else{
              throw e;
          }
      }
  }
docs: check if node is of specific type