title: Nodejs readdir - only find files
body: <p>When reading a directory, I currently have this:</p>
  <pre><code>  fs.readdir(tests, (err, items) =&gt; {
  
        if(err){
          return cb(err);
        }
  
        const cmd = items.filter(v =&gt; fs.lstatSync(tests + '/' + v).isFile());
  
        k.stdin.end(`${cmd}`);
    });
  </code></pre>
  <p>first of all I need a try/catch in there around fs.lstatSync, which I don't want to add. <strong>But is there a way to use <code>fs.readdir</code> to only find files?</strong></p>
  <p>Something like:</p>
  <pre><code>fs.readdir(tests, {type:'f'}, (err, items) =&gt; {});
  </code></pre>
  <p>does anyone know how?</p>