Comparing version
14
index.js
/*! | ||
* is-extglob <https://github.com/jonschlinkert/is-extglob> | ||
* | ||
* Copyright (c) 2014-2015, Jon Schlinkert. | ||
* Copyright (c) 2014-2016, Jon Schlinkert. | ||
* Licensed under the MIT License. | ||
@@ -9,4 +9,12 @@ */ | ||
module.exports = function isExtglob(str) { | ||
return typeof str === 'string' | ||
&& /[@?!+*]\(/.test(str); | ||
if (!str || typeof str !== 'string') { | ||
return false; | ||
} | ||
var m, matches = []; | ||
while ((m = /(\\).|([@?!+*]\(.*\))/g.exec(str))) { | ||
if (m[2]) matches.push(m[2]); | ||
str = str.slice(m.index + m[0].length); | ||
} | ||
return matches.length; | ||
}; |
{ | ||
"name": "is-extglob", | ||
"description": "Returns true if a string has an extglob.", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"homepage": "https://github.com/jonschlinkert/is-extglob", | ||
"author": { | ||
"name": "Jon Schlinkert", | ||
"url": "https://github.com/jonschlinkert" | ||
}, | ||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"repository": "jonschlinkert/is-extglob", | ||
@@ -16,3 +13,5 @@ "bugs": { | ||
"files": [ | ||
"index.js" | ||
"index.js", | ||
"LICENSE", | ||
"README.md" | ||
], | ||
@@ -24,8 +23,7 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "mocha", | ||
"prepublish": "browserify -o browser.js -e index.js" | ||
"test": "mocha" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*", | ||
"should": "*" | ||
"gulp-format-md": "^0.1.10", | ||
"mocha": "^3.0.2" | ||
}, | ||
@@ -37,7 +35,8 @@ "keywords": [ | ||
"exec", | ||
"expression", | ||
"extglob", | ||
"expression", | ||
"glob", | ||
"globbing", | ||
"globstar", | ||
"is", | ||
"match", | ||
@@ -50,3 +49,27 @@ "matches", | ||
"test" | ||
] | ||
} | ||
], | ||
"verb": { | ||
"toc": false, | ||
"layout": "default", | ||
"tasks": [ | ||
"readme" | ||
], | ||
"plugins": [ | ||
"gulp-format-md" | ||
], | ||
"related": { | ||
"list": [ | ||
"is-glob", | ||
"micromatch", | ||
"has-glob" | ||
] | ||
}, | ||
"reflinks": [ | ||
"verb", | ||
"verb-generate-readme" | ||
], | ||
"lint": { | ||
"reflinks": true | ||
} | ||
} | ||
} |
@@ -1,9 +0,11 @@ | ||
# is-extglob [](http://badge.fury.io/js/is-extglob) [](https://travis-ci.org/jonschlinkert/is-extglob) | ||
# is-extglob [](https://www.npmjs.com/package/is-extglob) [](https://npmjs.org/package/is-extglob) [](https://travis-ci.org/jonschlinkert/is-extglob) | ||
> Returns true if a string has an extglob. | ||
## Install with [npm](npmjs.org) | ||
## Install | ||
```bash | ||
npm i is-extglob --save | ||
Install with [npm](https://www.npmjs.com/): | ||
```sh | ||
$ npm install --save is-extglob | ||
``` | ||
@@ -29,2 +31,12 @@ | ||
Escaped extglobs: | ||
```js | ||
isExtglob('\\?(abc)'); | ||
isExtglob('\\@(abc)'); | ||
isExtglob('\\!(abc)'); | ||
isExtglob('\\*(abc)'); | ||
isExtglob('\\+(abc)'); | ||
``` | ||
Everything else... | ||
@@ -46,32 +58,52 @@ | ||
## Related | ||
* [extglob](https://github.com/jonschlinkert/extglob): Extended globs. extglobs add the expressive power of regular expressions to glob patterns. | ||
* [micromatch](https://github.com/jonschlinkert/micromatch): Glob matching for javascript/node.js. A faster alternative to minimatch (10-45x faster on avg), with all the features you're used to using in your Grunt and gulp tasks. | ||
* [parse-glob](https://github.com/jonschlinkert/parse-glob): Parse a glob pattern into an object of tokens. | ||
## History | ||
## Run tests | ||
Install dev dependencies. | ||
**v2.0** | ||
```bash | ||
npm i -d && npm test | ||
Adds support for escaping. Escaped exglobs no longer return true. | ||
## About | ||
### Related projects | ||
* [has-glob](https://www.npmjs.com/package/has-glob): Returns `true` if an array has a glob pattern. | [homepage](https://github.com/jonschlinkert/has-glob "Returns `true` if an array has a glob pattern.") | ||
* [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern or an extglob pattern… [more](https://github.com/jonschlinkert/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob "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 bet") | ||
* [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | [homepage](https://github.com/jonschlinkert/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.") | ||
### Contributing | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). | ||
### Building docs | ||
_(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).)_ | ||
To generate the readme and API documentation with [verb](https://github.com/verbose/verb): | ||
```sh | ||
$ npm install -g verb verb-generate-readme && verb | ||
``` | ||
### Running tests | ||
## Contributing | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/is-extglob/issues) | ||
Install dev dependencies: | ||
```sh | ||
$ npm install -d && npm test | ||
``` | ||
## Author | ||
### Author | ||
**Jon Schlinkert** | ||
+ [github/jonschlinkert](https://github.com/jonschlinkert) | ||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
## License | ||
Copyright (c) 2015 Jon Schlinkert | ||
Released under the MIT license | ||
* [github/jonschlinkert](https://github.com/jonschlinkert) | ||
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
### License | ||
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT license](https://github.com/jonschlinkert/is-extglob/blob/master/LICENSE). | ||
*** | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 06, 2015._ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.30, on September 03, 2016._ |
Sorry, the diff of this file is not supported yet
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
6254
49.8%17
70%107
42.67%0
-100%