This blog post suggests trying to read the file and reacting to the exception that will be thrown if it is a folder.
if (!f.type && f.size%4096 == 0 && f.size <= 102400) {
try {
reader = new FileReader();
reader.readAsBinaryString(f);
} catch (NS_ERROR_FILE_ACCESS_DENIED) {
//file is a directory
}
}
In general: First assume the folder is a file and treat it like one, at some point things will go wrong and you can react to that.