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'}
})();
npm install glob-set
const globSet = require('glob-set');
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
andcatch
, and will be resolved or rejected just likePromise
. - Doesn't support the third
cb
parameter. silent
option andstrict
option 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}`);
});
ISC License © 2017 Shinnosuke Watanabe