title: How to get first X files with node glob
body: <p>Using <a href="https://github.com/isaacs/node-glob" rel="nofollow">node-glob</a>, is it possible to specify a pattern that will return only the first X matching files, rather than all matches?</p>
  
  <p>For example, if I wanted all JavaScript files, my pattern would be <code>**/*.js</code>. But what if I only wanted the first 5 JavaScript files?</p>
  
  <p>I realize that there are other options, such as I could take the resulting fileset array and slice it. The underlying case here makes that difficult, so I am trying to accomplish this directly from the glob pattern.</p>