Check if a file or folder exists

Is there an API to check if a file or folder exists? I don’t see anything in the API.

// from the documentation it looks like I have call file.getEntry() and test for an error event or find a matching name

Test for error:

try {
	var entry = await folder.getEntry(filename);
	fileExists = true;
}
catch(fileError) {
	fileExists = false;
}

Test for matching name:

  try {

    subfolder = (await folder.getEntries()).find(entry => entry.name.includes(subfolderName));

    if (subfolder!=null) {
      return true;
    }
  }
  catch(error) {
    return false;
  }

This seems to work:

/**
 * Returns true if a subfolder exists
 * @param {File} folder file of type folder  
 * @param {String} subfolderName name of sub folder
 * @returns {Boolean} returns true if folder exists
 */
async function checkSubFolderExists(folder, subfolderName) {
  var subfolder = null;

  try {
    subfolder = (await folder.getEntries()).find(entry => entry.name.includes(subfolderName));

    if (subfolder!=null && subfolder.isFolder) {
      return true;
    }
  }
  catch(fileError) {
    log(fileError);
  }

  return false;
}