Licence
MIT
Version
1.0.1
Deps
4
Vulns
0
Weekly
0
glob-set
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
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
Setinstance, instead of an array. - The returned object has an additional methods
thenandcatch, and will be resolved or rejected just likePromise. - Doesn't support the third
cbparameter. silentoption andstrictoption default totrue.- 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