https://github.com/ahmadnassri/node-glob-promise
Promise version of glob
https://github.com/ahmadnassri/node-glob-promise
lib node
Last synced: about 1 year ago
JSON representation
Promise version of glob
- Host: GitHub
- URL: https://github.com/ahmadnassri/node-glob-promise
- Owner: ahmadnassri
- License: mit
- Created: 2015-06-19T22:37:41.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2025-01-07T20:53:23.000Z (over 1 year ago)
- Last Synced: 2025-04-01T05:34:06.550Z (about 1 year ago)
- Topics: lib, node
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/glob-promise
- Size: 564 KB
- Stars: 53
- Watchers: 2
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Promise version of glob
Match files using the patterns the shell uses, like stars and stuff.
[![license][license-img]][license-url]
[![release][release-img]][release-url]
[![semantic][semantic-img]][semantic-url]
> ***Note**: This is just a [`Promise`][] wrapped version of [`glob`][]*
> \[!IMPORTANT\]
> [Glob][`glob`] has native Promise support as of `v9.0.0`, please use it directly.
> I will not issue a deprecation notice on this package, because I can't deal with the volume of angry tickets that will follow.
## Install
``` bash
npm install glob-promise glob
```
###### NOTE
[`glob`][] is set as a `peerDependency` in [`package.json`][]
- `npm` \>= 7 will automatically install `peerDependencies`
- `npm` \<= 6 will **not** automatically install `peerDependencies`.
You will need to manually add `glob` as a dependency to your project for `glob-promise` to work.
## API
### `glob(pattern [, options])`
Alias for `glob.promise`
### `glob.promise(pattern [, options])`
*pattern*: `String` (glob pattern)
*options*: `Object` or `String`
Return: `Object` ([Promise][`Promise`])
When it finishes, it will be [*fulfilled*][] with an `Array` of filenames as its first argument.
When it fails to read the files, it will be [*rejected*][] with an error as its first argument.
``` js
glob('**/*')
.then(function(contents) {
contents; //=> ['lorem', 'ipsum', 'dolor']
});
glob('{foo,bar.baz}.txt', { nobrace: true })
.then(function(contents) {
contents; //=> []
});
```
### `glob.glob(pattern [, options], cb)`
> see [`glob`][1]
### `glob.sync(pattern [, options])`
> see [`glob.sync()`][]
### `glob.hasMagic(pattern, [options])`
> see [`glob.hasMagic()`][]
### `Class: glob.Glob`
> see [`Glob`][2]
#### options
The option object will be directly passed to [glob][].
[`Promise`]: http://promisesaplus.com/
[`glob`]: https://github.com/isaacs/node-glob
[`package.json`]: package.json
[*fulfilled*]: http://promisesaplus.com/#point-26
[*rejected*]: http://promisesaplus.com/#point-30
[1]: https://github.com/isaacs/node-glob#globpattern-options-cb
[`glob.sync()`]: https://github.com/isaacs/node-glob#globsyncpattern-options
[`glob.hasMagic()`]: https://github.com/isaacs/node-glob#globhasmagicpattern-options
[2]: https://github.com/isaacs/node-glob#class-globglob
[glob]: https://github.com/isaacs/node-glob#options
----
> Author: [Ahmad Nassri](https://www.ahmadnassri.com/) •
> Twitter: [@AhmadNassri](https://twitter.com/AhmadNassri)
[license-url]: LICENSE
[license-img]: https://badgen.net/github/license/ahmadnassri/node-glob-promise
[release-url]: https://github.com/ahmadnassri/node-glob-promise/releases
[release-img]: https://badgen.net/github/release/ahmadnassri/node-glob-promise
[semantic-url]: https://github.com/ahmadnassri/node-glob-promise/actions?query=workflow%3Arelease
[semantic-img]: https://badgen.net/badge/📦/semantically%20released/blue