1.0.1 • Published 6 years ago
glob-set v1.0.1
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
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}`);
});
License
ISC License © 2017 Shinnosuke Watanabe