wishthis/node_modules/is-glob/README.md

142 lines
5.1 KiB
Markdown
Raw Normal View History

2022-04-08 10:55:35 +00:00
# is-glob [![NPM version](https://img.shields.io/npm/v/is-glob.svg?style=flat)](https://www.npmjs.com/package/is-glob) [![NPM downloads](https://img.shields.io/npm/dm/is-glob.svg?style=flat)](https://npmjs.org/package/is-glob) [![Build Status](https://img.shields.io/travis/jonschlinkert/is-glob.svg?style=flat)](https://travis-ci.org/jonschlinkert/is-glob)
2022-01-21 08:28:41 +00:00
> Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a better user experience.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save is-glob
```
You might also be interested in [is-valid-glob](https://github.com/jonschlinkert/is-valid-glob) and [has-glob](https://github.com/jonschlinkert/has-glob).
## Usage
```js
var isGlob = require('is-glob');
```
**True**
Patterns that have glob characters or regex patterns will return `true`:
```js
isGlob('!foo.js');
isGlob('*.js');
isGlob('**/abc.js');
isGlob('abc/*.js');
isGlob('abc/(aaa|bbb).js');
isGlob('abc/[a-z].js');
isGlob('abc/{a,b}.js');
2022-04-08 10:55:35 +00:00
isGlob('abc/?.js');
2022-01-21 08:28:41 +00:00
//=> true
```
Extglobs
```js
isGlob('abc/@(a).js');
isGlob('abc/!(a).js');
isGlob('abc/+(a).js');
isGlob('abc/*(a).js');
isGlob('abc/?(a).js');
//=> true
```
**False**
Escaped globs or extglobs return `false`:
```js
isGlob('abc/\\@(a).js');
isGlob('abc/\\!(a).js');
isGlob('abc/\\+(a).js');
isGlob('abc/\\*(a).js');
isGlob('abc/\\?(a).js');
isGlob('\\!foo.js');
isGlob('\\*.js');
isGlob('\\*\\*/abc.js');
isGlob('abc/\\*.js');
isGlob('abc/\\(aaa|bbb).js');
isGlob('abc/\\[a-z].js');
isGlob('abc/\\{a,b}.js');
2022-04-08 10:55:35 +00:00
isGlob('abc/\\?.js');
2022-01-21 08:28:41 +00:00
//=> false
```
Patterns that do not have glob patterns return `false`:
```js
isGlob('abc.js');
isGlob('abc/def/ghi.js');
isGlob('foo.js');
isGlob('abc/@.js');
isGlob('abc/+.js');
isGlob();
isGlob(null);
//=> false
```
Arrays are also `false` (If you want to check if an array has a glob pattern, use [has-glob](https://github.com/jonschlinkert/has-glob)):
```js
isGlob(['**/*.js']);
isGlob(['foo.js']);
//=> false
```
2022-04-08 10:55:35 +00:00
## About
2022-01-21 08:28:41 +00:00
2022-04-08 10:55:35 +00:00
### Related projects
2022-01-21 08:28:41 +00:00
2022-04-08 10:55:35 +00:00
* [assemble](https://www.npmjs.com/package/assemble): Get the rocks out of your socks! Assemble makes you fast at creating web projects… [more](https://github.com/assemble/assemble) | [homepage](https://github.com/assemble/assemble "Get the rocks out of your socks! Assemble makes you fast at creating web projects. Assemble is used by thousands of projects for rapid prototyping, creating themes, scaffolds, boilerplates, e-books, UI components, API documentation, blogs, building websit")
* [base](https://www.npmjs.com/package/base): base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… [more](https://github.com/node-base/base) | [homepage](https://github.com/node-base/base "base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting with a handful of common methods, like `set`, `get`, `del` and `use`.")
* [update](https://www.npmjs.com/package/update): Be scalable! Update is a new, open source developer framework and CLI for automating updates… [more](https://github.com/update/update) | [homepage](https://github.com/update/update "Be scalable! Update is a new, open source developer framework and CLI for automating updates of any kind in code projects.")
* [verb](https://www.npmjs.com/package/verb): Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… [more](https://github.com/verbose/verb) | [homepage](https://github.com/verbose/verb "Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used on hundreds of projects of all sizes to generate everything from API docs to readmes.")
2022-01-21 08:28:41 +00:00
2022-04-08 10:55:35 +00:00
### Contributing
2022-01-21 08:28:41 +00:00
2022-04-08 10:55:35 +00:00
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
2022-01-21 08:28:41 +00:00
2022-04-08 10:55:35 +00:00
### Contributors
2022-01-21 08:28:41 +00:00
2022-04-08 10:55:35 +00:00
| **Commits** | **Contributor**<br/> |
| --- | --- |
| 40 | [jonschlinkert](https://github.com/jonschlinkert) |
| 1 | [tuvistavie](https://github.com/tuvistavie) |
2022-01-21 08:28:41 +00:00
2022-04-08 10:55:35 +00:00
### Building docs
2022-01-21 08:28:41 +00:00
2022-04-08 10:55:35 +00:00
_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_
2022-01-21 08:28:41 +00:00
2022-04-08 10:55:35 +00:00
To generate the readme and API documentation with [verb](https://github.com/verbose/verb):
2022-01-21 08:28:41 +00:00
```sh
2022-04-08 10:55:35 +00:00
$ npm install -g verb verb-generate-readme && verb
2022-01-21 08:28:41 +00:00
```
2022-04-08 10:55:35 +00:00
### Running tests
2022-01-21 08:28:41 +00:00
2022-04-08 10:55:35 +00:00
Install dev dependencies:
2022-01-21 08:28:41 +00:00
```sh
2022-04-08 10:55:35 +00:00
$ npm install -d && npm test
2022-01-21 08:28:41 +00:00
```
### Author
**Jon Schlinkert**
2022-04-08 10:55:35 +00:00
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
2022-01-21 08:28:41 +00:00
### License
2022-04-08 10:55:35 +00:00
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT license](https://github.com/jonschlinkert/is-glob/blob/master/LICENSE).
2022-01-21 08:28:41 +00:00
***
2022-04-08 10:55:35 +00:00
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.31, on October 12, 2016._