/glob-set

Like node-glob, but provides matched paths as a `Set` instead of an `Array`

Primary LanguageJavaScriptISC LicenseISC

glob-set

npm version Build Status Coverage Status

Like node-glob, but provides results as a Set instead of an Array

const globSet = require('glob-set');

(async () => {
  const found = await globSet('*.js'); //=> Set {'index.js', 'test.js'}
})();

Installation

Use npm.

npm install glob-set

API

const globSet = require('glob-set');

globSet(pattern [, options])

pattern: string (glob pattern)
options: Object (glob options)
Return: Glob instance with the additional Promise prototype methods

Differences from glob

  • Produces the result as a Set instance, instead of an array.
  • The returned object has an additional methods then and catch, and will be resolved or rejected just like Promise.
  • Doesn't support the third cb parameter.
  • silent option and strict option default to true.
  • Synchronous processing is not supported.
globSet('*', {cwd: 'node_modules'}).then(found => {
  for (const path of found) {
    console.log(path); // abbrev, acorn, acorn-jsx, ...
  }
}, err => {
  console.error(`An error occurred: ${err.message}`);
});

License

ISC License © 2017 Shinnosuke Watanabe