Get number of files in the directory

Is there a property that tells you the number of files in a folder? Does this tell you if there are hidden items in the folder? I do not want to my plugin to delete a folder if it has any items in it but users wants me to create sub folders.

I have this but I would think a property might exist already:

 * Gets number of files in a folder
 * @param {File} folder folder  
 * @returns {Number} returns number of files in a folder
async function getNumberOfFiles(folder) {
  var entries = [];

  try {
    entries = await folder.getEntries();

    if (entries!=null && folder.isFolder) {
      return entries.length;
  catch(fileError) {

  return 0;