title: How to read a directory and know the files type?
body: <p>If we want to read a folder, we can:</p>
  
  <pre><code>const fs = require('fs')
  
  let folderName = 'Any_folder_name'
  
  fs.readdir(folderName,(err,files)=&gt;{
      if (err) throw err;
  
      console.log(files)
      // this is a files' name list in this folder
  })
  </code></pre>
  
  <p>but the return value is only a list of files name. Such as <code>['README.md','src']</code>.</p>
  
  <p>But I want to konw which is a file and which is a folder. How to do this?</p>
  
  <p>I know we can use a loop to this list and <code>fs.stats</code> to confirm which is a folder.</p>
  
  <p>But I want to know if there is a more effcient way to do this? </p>