Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/glob-set
Like node-glob, but provides matched paths as a `Set` instead of an `Array`
https://github.com/shinnn/glob-set
gather glob matching pattern promise search set wildcards
Last synced: 27 days ago
JSON representation
Like node-glob, but provides matched paths as a `Set` instead of an `Array`
- Host: GitHub
- URL: https://github.com/shinnn/glob-set
- Owner: shinnn
- License: isc
- Created: 2017-01-31T11:16:45.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-30T01:26:06.000Z (about 6 years ago)
- Last Synced: 2024-09-25T05:37:54.644Z (about 2 months ago)
- Topics: gather, glob, matching, pattern, promise, search, set, wildcards
- Language: JavaScript
- Homepage:
- Size: 53.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# glob-set
[![npm version](https://img.shields.io/npm/v/glob-set.svg)](https://www.npmjs.com/package/glob-set)
[![Build Status](https://travis-ci.org/shinnn/glob-set.svg?branch=master)](https://travis-ci.org/shinnn/glob-set)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/glob-set.svg)](https://coveralls.io/github/shinnn/glob-set?branch=master)Like [node-glob](https://github.com/isaacs/node-glob), but provides results as a [`Set`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set) instead of an `Array`
```javascript
const globSet = require('glob-set');(async () => {
const found = await globSet('*.js'); //=> Set {'index.js', 'test.js'}
})();
```## Installation
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm).
```
npm install glob-set
```## API
```javascript
const globSet = require('glob-set');
```### globSet(*pattern* [, *options*])
*pattern*: `string` ([glob pattern](https://github.com/isaacs/node-glob#glob-primer))
*options*: `Object` ([`glob` options](https://github.com/isaacs/node-glob#options))
Return: [`Glob`](https://github.com/isaacs/node-glob#class-globglob) instance with the additional [`Promise` prototype methods](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise#Methods_2)#### Differences from [`glob`](https://github.com/isaacs/node-glob#globpattern-options-cb)
* Produces the result as a [`Set`](http://www.2ality.com/2015/01/es6-maps-sets.html#set) instance, instead of an array.
* The returned object has an additional methods [`then`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/then) and [`catch`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch), and will be resolved or rejected just like [`Promise`](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise).
* Doesn't support the third `cb` parameter.
* `silent` option and `strict` option default to `true`.
* Synchronous processing is not supported.```javascript
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](./LICENSE) © 2017 Shinnosuke Watanabe