Socket
Socket
Sign inDemoInstall

extglob

Package Overview
Dependencies
57
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.2 to 1.0.0

changelog.md

352

index.js

@@ -1,8 +0,1 @@

/*!
* extglob <https://github.com/jonschlinkert/extglob>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';

@@ -14,25 +7,28 @@

var isExtglob = require('is-extglob');
var re, cache = {};
var debug = require('debug')('extglob');
var extend = require('extend-shallow');
var unique = require('array-unique');
var toRegex = require('to-regex');
/**
* Expose `extglob`
* Local dependencies
*/
module.exports = extglob;
var compilers = require('./lib/compilers');
var parsers = require('./lib/parsers');
var Extglob = require('./lib/extglob');
var utils = require('./lib/utils');
var MAX_LENGTH = 1024 * 64;
/**
* Convert the given extglob `string` to a regex-compatible
* string.
* Convert the given `extglob` pattern into a regex-compatible string. Returns
* an object with the compiled result and the parsed AST.
*
* ```js
* var extglob = require('extglob');
* extglob('!(a?(b))');
* //=> '(?!a(?:b)?)[^/]*?'
* console.log(extglob('*.!(*a)'));
* //=> '(?!\\.)[^/]*?\\.(?!(?!\\.)[^/]*?a\\b).*?'
* ```
*
* @param {String} `str` The string to convert.
* @param {String} `pattern`
* @param {Object} `options`
* @option {Boolean} [options] `esc` If `false` special characters will not be escaped. Defaults to `true`.
* @option {Boolean} [options] `regex` If `true` a regular expression is returned instead of a string.
* @return {String}

@@ -42,139 +38,261 @@ * @api public

function extglob(pattern, options) {
debug('initializing from <%s>', __filename);
var res = extglob.create(pattern, options);
return res.output;
}
function extglob(str, opts) {
opts = opts || {};
var o = {}, i = 0;
/**
* Cache
*/
// fix common character reversals
// '*!(.js)' => '*.!(js)'
str = str.replace(/!\(([^\w*()])/g, '$1!(');
extglob.cache = utils.cache;
extglob.clearCache = function() {
extglob.cache.__data__ = {};
};
// support file extension negation
str = str.replace(/([*\/])\.!\([*]\)/g, function (m, ch) {
if (ch === '/') {
return escape('\\/[^.]+');
/**
* Takes an array of strings and an extglob pattern and returns a new
* array that contains only the strings that match the pattern.
*
* ```js
* var extglob = require('extglob');
* console.log(extglob.match(['a.a', 'a.b', 'a.c'], '*.!(*a)'));
* //=> ['a.b', 'a.c']
* ```
* @param {Array} `list` Array of strings to match
* @param {String} `pattern` Extglob pattern
* @param {Object} `options`
* @return {Array} Returns an array of matches
* @api public
*/
extglob.match = function(list, pattern, options) {
if (typeof pattern !== 'string') {
throw new TypeError('expected pattern to be a string');
}
list = utils.arrayify(list);
var isMatch = extglob.matcher(pattern, options);
var len = list.length;
var idx = -1;
var matches = [];
while (++idx < len) {
var ele = list[idx];
if (isMatch(ele)) {
matches.push(ele);
}
return escape('[^.]+');
});
}
// create a unique key for caching by
// combining the string and options
var key = str
+ String(!!opts.regex)
+ String(!!opts.contains)
+ String(!!opts.escape);
// if no options were passed, uniquify results and return
if (typeof options === 'undefined') {
return unique(matches);
}
if (cache.hasOwnProperty(key)) {
return cache[key];
if (matches.length === 0) {
if (options.failglob === true) {
throw new Error('no matches found for "' + pattern + '"');
}
if (options.nonull === true || options.nullglob === true) {
return [pattern.split('\\').join('')];
}
}
if (!(re instanceof RegExp)) {
re = regex();
return options.nodupes !== false ? unique(matches) : matches;
};
/**
* Returns true if the specified `string` matches the given
* extglob `pattern`.
*
* ```js
* var extglob = require('extglob');
*
* console.log(extglob.isMatch('a.a', '*.!(*a)'));
* //=> false
* console.log(extglob.isMatch('a.b', '*.!(*a)'));
* //=> true
* ```
* @param {String} `string` String to match
* @param {String} `pattern` Extglob pattern
* @param {String} `options`
* @return {Boolean}
* @api public
*/
extglob.isMatch = function(str, pattern, options) {
if (typeof pattern !== 'string') {
throw new TypeError('expected pattern to be a string');
}
opts.negate = false;
var m;
if (typeof str !== 'string') {
throw new TypeError('expected a string');
}
while (m = re.exec(str)) {
var prefix = m[1];
var inner = m[3];
if (prefix === '!') {
opts.negate = true;
}
if (pattern === str) {
return true;
}
var id = '__EXTGLOB_' + (i++) + '__';
// use the prefix of the _last_ (outtermost) pattern
o[id] = wrap(inner, prefix, opts.escape);
str = str.split(m[0]).join(id);
if (pattern === '' || pattern === ' ' || pattern === '.') {
return pattern === str;
}
var keys = Object.keys(o);
var len = keys.length;
var isMatch = utils.memoize('isMatch', pattern, options, extglob.matcher);
return isMatch(str);
};
// we have to loop again to allow us to convert
// patterns in reverse order (starting with the
// innermost/last pattern first)
while (len--) {
var prop = keys[len];
str = str.split(prop).join(o[prop]);
/**
* Returns true if the given `string` contains the given pattern. Similar to `.isMatch` but
* the pattern can match any part of the string.
*
* ```js
* var extglob = require('extglob');
* console.log(extglob.contains('aa/bb/cc', '*b'));
* //=> true
* console.log(extglob.contains('aa/bb/cc', '*d'));
* //=> false
* ```
* @param {String} `str` The string to match.
* @param {String} `pattern` Glob pattern to use for matching.
* @param {Object} `options`
* @return {Boolean} Returns true if the patter matches any part of `str`.
* @api public
*/
extglob.contains = function(str, pattern, options) {
if (typeof str !== 'string') {
throw new TypeError('expected a string');
}
var result = opts.regex
? toRegex(str, opts.contains, opts.negate)
: str;
if (pattern === '' || pattern === ' ' || pattern === '.') {
return pattern === str;
}
result = result.split('.').join('\\.');
var opts = extend({}, options, {contains: true});
opts.strictClose = false;
opts.strictOpen = false;
return extglob.isMatch(str, pattern, opts);
};
// cache the result and return it
return (cache[key] = result);
}
/**
* Takes an extglob pattern and returns a matcher function. The returned
* function takes the string to match as its only argument.
*
* ```js
* var extglob = require('extglob');
* var isMatch = extglob.matcher('*.!(*a)');
*
* console.log(isMatch('a.a'));
* //=> false
* console.log(isMatch('a.b'));
* //=> true
* ```
* @param {String} `pattern` Extglob pattern
* @param {String} `options`
* @return {Boolean}
* @api public
*/
extglob.matcher = function(pattern, options) {
if (typeof pattern !== 'string') {
throw new TypeError('expected pattern to be a string');
}
function matcher() {
var re = extglob.makeRe(pattern, options);
return function(str) {
return re.test(str);
};
}
return utils.memoize('matcher', pattern, options, matcher);
};
/**
* Convert `string` to a regex string.
* Convert the given `extglob` pattern into a regex-compatible string. Returns
* an object with the compiled result and the parsed AST.
*
* @param {String} `str`
* @param {String} `prefix` Character that determines how to wrap the string.
* @param {Boolean} `esc` If `false` special characters will not be escaped. Defaults to `true`.
* ```js
* var extglob = require('extglob');
* console.log(extglob.create('*.!(*a)').output);
* //=> '(?!\\.)[^/]*?\\.(?!(?!\\.)[^/]*?a\\b).*?'
* ```
* @param {String} `str`
* @param {Object} `options`
* @return {String}
* @api public
*/
function wrap(inner, prefix, esc) {
if (esc) inner = escape(inner);
extglob.create = function(pattern, options) {
if (typeof pattern !== 'string') {
throw new TypeError('expected pattern to be a string');
}
switch (prefix) {
case '!':
return '(?!' + inner + ')[^/]' + (esc ? '%%%~' : '*?');
case '@':
return '(?:' + inner + ')';
case '+':
return '(?:' + inner + ')+';
case '*':
return '(?:' + inner + ')' + (esc ? '%%' : '*')
case '?':
return '(?:' + inner + '|)';
default:
return inner;
function create() {
var ext = new Extglob(options);
var ast = ext.parse(pattern, options);
return ext.compile(ast, options);
}
}
function escape(str) {
str = str.split('*').join('[^/]%%%~');
str = str.split('.').join('\\.');
return str;
}
return utils.memoize('create', pattern, options, create);
};
/**
* extglob regex.
* Create a regular expression from the given `pattern` and `options`.
*
* ```js
* var extglob = require('extglob');
* var re = extglob.makeRe('*.!(*a)');
* console.log(re);
* //=> /^[^\/]*?\.(?![^\/]*?a)[^\/]*?$/
* ```
* @param {String} `pattern` The pattern to convert to regex.
* @param {Object} `options`
* @return {RegExp}
* @api public
*/
function regex() {
return /(\\?[@?!+*$]\\?)(\(([^()]*?)\))/;
}
extglob.makeRe = function(pattern, options) {
if (pattern instanceof RegExp) {
return pattern;
}
if (typeof pattern !== 'string') {
throw new TypeError('expected pattern to be a string');
}
if (pattern.length > MAX_LENGTH) {
throw new Error('expected pattern to be less than ' + MAX_LENGTH + ' characters');
}
function makeRe() {
var opts = extend({strictErrors: false}, options);
if (opts.strictErrors === true) opts.strict = true;
var res = extglob.create(pattern, opts);
return toRegex(res.output, opts);
}
var regex = utils.memoize('makeRe', pattern, options, makeRe);
if (regex.source.length > MAX_LENGTH) {
throw new SyntaxError('potentially malicious regex detected');
}
return regex;
};
/**
* Negation regex
* Expose `Extglob` constructor, parsers and compilers
*/
function negate(str) {
return '(?!^' + str + ').*$';
}
extglob.Extglob = Extglob;
extglob.compilers = compilers;
extglob.parsers = parsers;
/**
* Create the regex to do the matching. If
* the leading character in the `pattern` is `!`
* a negation regex is returned.
*
* @param {String} `pattern`
* @param {Boolean} `contains` Allow loose matching.
* @param {Boolean} `isNegated` True if the pattern is a negation pattern.
* Expose `extglob`
* @type {Function}
*/
function toRegex(pattern, contains, isNegated) {
var prefix = contains ? '^' : '';
var after = contains ? '$' : '';
pattern = ('(?:' + pattern + ')' + after);
if (isNegated) {
pattern = prefix + negate(pattern);
}
return new RegExp(prefix + pattern);
}
module.exports = extglob;
{
"name": "extglob",
"description": "Convert extended globs to regex-compatible strings. Add (almost) the expressive power of regular expressions to glob patterns.",
"version": "0.3.2",
"description": "Extended glob support for JavaScript. Adds (almost) the expressive power of regular expressions to glob patterns.",
"version": "1.0.0",
"homepage": "https://github.com/jonschlinkert/extglob",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"repository": {
"type": "git",
"url": "git://github.com/jonschlinkert/extglob.git"
},
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"contributors": [
"Isiah Meadows <me@isiahmeadows.com> (https://www.isiahmeadows.com)",
"Jon Schlinkert <jon.schlinkert@sellside.com> (http://twitter.com/jonschlinkert)",
"Shinnosuke Watanabe <snnskwtnb@gmail.com> (https://shinnn.github.io)"
],
"repository": "jonschlinkert/extglob",
"bugs": {

@@ -19,3 +18,4 @@ "url": "https://github.com/jonschlinkert/extglob/issues"

"files": [
"index.js"
"index.js",
"lib"
],

@@ -30,12 +30,28 @@ "main": "index.js",

"dependencies": {
"is-extglob": "^1.0.0"
"array-unique": "^0.3.2",
"debug": "^2.2.0",
"define-property": "^0.2.5",
"expand-brackets": "^2.0.1",
"extend-shallow": "^2.0.1",
"fragment-cache": "^0.2.0",
"regex-not": "^1.0.0",
"snapdragon": "^0.8.1",
"to-regex": "^2.1.0"
},
"devDependencies": {
"ansi-green": "^0.1.1",
"micromatch": "^2.1.6",
"minimatch": "^2.0.1",
"minimist": "^1.1.0",
"mocha": "*",
"should": "*",
"success-symbol": "^0.1.0"
"bash-match": "^0.1.1",
"for-own": "^0.1.4",
"gulp": "^3.9.1",
"gulp-eslint": "^3.0.1",
"gulp-format-md": "^0.1.11",
"gulp-istanbul": "^1.1.1",
"gulp-mocha": "^3.0.1",
"gulp-unused": "^0.2.0",
"helper-changelog": "^0.3.0",
"is-windows": "^0.2.0",
"micromatch": "^2.3.11",
"minimatch": "^3.0.3",
"mocha": "^3.1.2",
"multimatch": "^2.1.0",
"yargs-parser": "^4.0.2"
},

@@ -47,17 +63,40 @@ "keywords": [

"glob",
"globbing",
"ksh",
"match",
"pattern",
"patterns",
"regex",
"test",
"wildcard"
],
"verb": {
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"related": {
"list": [
"micromatch",
"braces",
"expand-brackets",
"braces",
"expand-range",
"fill-range",
"expand-range"
"micromatch"
]
}
},
"helpers": [
"helper-changelog"
],
"plugins": [
"gulp-format-md"
],
"lint": {
"reflinks": true
},
"reflinks": [
"verb",
"verb-generate-readme"
]
}
}

@@ -1,88 +0,329 @@

# extglob [![NPM version](https://badge.fury.io/js/extglob.svg)](http://badge.fury.io/js/extglob) [![Build Status](https://travis-ci.org/jonschlinkert/extglob.svg)](https://travis-ci.org/jonschlinkert/extglob)
# extglob [![NPM version](https://img.shields.io/npm/v/extglob.svg?style=flat)](https://www.npmjs.com/package/extglob) [![NPM monthly downloads](https://img.shields.io/npm/dm/extglob.svg?style=flat)](https://npmjs.org/package/extglob) [![NPM total downloads](https://img.shields.io/npm/dt/extglob.svg?style=flat)](https://npmjs.org/package/extglob) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/extglob.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/extglob) [![Windows Build Status](https://img.shields.io/appveyor/ci/jonschlinkert/extglob.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/jonschlinkert/extglob)
> Convert extended globs to regex-compatible strings. Add (almost) the expressive power of regular expressions to glob patterns.
> Extended glob support for JavaScript. Adds (almost) the expressive power of regular expressions to glob patterns.
Install with [npm](https://www.npmjs.com/)
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm i extglob --save
$ npm install --save extglob
```
Used by [micromatch](https://github.com/jonschlinkert/micromatch).
* Convert an extglob string to a regex-compatible string.
* More complete (and correct) support than [minimatch](https://github.com/isaacs/minimatch) (minimatch fails a large percentage of the extglob tests)
* Handles [negation patterns](#extglob-patterns)
* Handles [nested patterns](#extglob-patterns)
* Organized code base, easy to maintain and make changes when edge cases arise
* As you can see by the [benchmarks](#benchmarks), extglob doesn't pay with speed for it's completeness, accuracy and quality.
**Features**
**Heads up!**: This library only supports extglobs, to handle full glob patterns and other extended globbing features use [micromatch](https://github.com/jonschlinkert/micromatch) instead.
* Convert an extglob string to a regex-compatible string. **Only converts extglobs**, to handle full globs use [micromatch](https://github.com/jonschlinkert/micromatch).
* Pass `{regex: true}` to return a regex
* Handles nested patterns
* More complete (and correct) support than [minimatch](https://github.com/isaacs/minimatch)
## Usage
The main export is a function that takes a string and options, and returns an object with the parsed AST and the compiled `.output`, which is a regex-compatible string that can be used for matching.
```js
var extglob = require('extglob');
console.log(extglob('!(xyz)*.js'));
```
extglob('?(z)');
//=> '(?:z)?'
extglob('*(z)');
//=> '(?:z)*'
extglob('+(z)');
//=> '(?:z)+'
extglob('@(z)');
//=> '(?:z)'
extglob('!(z)');
//=> '(?!^(?:(?!z)[^/]*?)).*$'
## Extglob cheatsheet
Extended globbing patterns can be defined as follows (as described by the [bash man page](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html)):
| **pattern** | **regex equivalent** | **description** |
| --- | --- | --- |
| `?(pattern-list)` | `(... | ...)?` | Matches zero or one occurrence of the given pattern(s) |
| `*(pattern-list)` | `(... | ...)*` | Matches zero or more occurrences of the given pattern(s) |
| `+(pattern-list)` | `(... | ...)+` | Matches one or more occurrences of the given pattern(s) |
| `@(pattern-list)` | `(... | ...)` <sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup> | Matches one of the given pattern(s) |
| `!(pattern-list)` | N/A | Matches anything except one of the given pattern(s) |
## API
### [extglob](index.js#L37)
Convert the given `extglob` pattern into a regex-compatible string. Returns an object with the compiled result and the parsed AST.
**Example**
```js
var extglob = require('extglob');
console.log(extglob('*.!(*a)'));
//=> '(?!\\.)[^/]*?\\.(?!(?!\\.)[^/]*?a\\b).*?'
```
**Optionally return regex**
**Params**
* `pattern` **{String}**
* `options` **{Object}**
* `returns` **{String}**
### [.match](index.js#L68)
Takes an array of strings and an extglob pattern and returns a new array that contains only the strings that match the pattern.
**Example**
```js
extglob('!(z)', {regex: true});
//=> /(?!^(?:(?!z)[^/]*?)).*$/
var extglob = require('extglob');
console.log(extglob.match(['a.a', 'a.b', 'a.c'], '*.!(*a)'));
//=> ['a.b', 'a.c']
```
## Extglob patterns
**Params**
To learn more about how extglobs work, see the docs for [Bash pattern matching](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html):
* `list` **{Array}**: Array of strings to match
* `pattern` **{String}**: Extglob pattern
* `options` **{Object}**
* `returns` **{Array}**: Returns an array of matches
* `?(pattern)`: Match zero or one occurrence of the given pattern.
* `*(pattern)`: Match zero or more occurrences of the given pattern.
* `+(pattern)`: Match one or more occurrences of the given pattern.
* `@(pattern)`: Match one of the given pattern.
* `!(pattern)`: Match anything except one of the given pattern.
### [.isMatch](index.js#L123)
## Related
Returns true if the specified `string` matches the given extglob `pattern`.
* [braces](https://github.com/jonschlinkert/braces): Fastest brace expansion for node.js, with the most complete support for the Bash 4.3 braces… [more](https://github.com/jonschlinkert/braces)
* [expand-brackets](https://github.com/jonschlinkert/expand-brackets): Expand POSIX bracket expressions (character classes) in glob patterns.
* [expand-range](https://github.com/jonschlinkert/expand-range): Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See… [more](https://github.com/jonschlinkert/expand-range)
* [fill-range](https://github.com/jonschlinkert/fill-range): Fill in a range of numbers or letters, optionally passing an increment or multiplier to… [more](https://github.com/jonschlinkert/fill-range)
* [micromatch](https://github.com/jonschlinkert/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just… [more](https://github.com/jonschlinkert/micromatch)
**Example**
## Run tests
```js
var extglob = require('extglob');
Install dev dependencies:
console.log(extglob.isMatch('a.a', '*.!(*a)'));
//=> false
console.log(extglob.isMatch('a.b', '*.!(*a)'));
//=> true
```
**Params**
* `string` **{String}**: String to match
* `pattern` **{String}**: Extglob pattern
* `options` **{String}**
* `returns` **{Boolean}**
### [.contains](index.js#L162)
Returns true if the given `string` contains the given pattern. Similar to `.isMatch` but the pattern can match any part of the string.
**Example**
```js
var extglob = require('extglob');
console.log(extglob.contains('aa/bb/cc', '*b'));
//=> true
console.log(extglob.contains('aa/bb/cc', '*d'));
//=> false
```
**Params**
* `str` **{String}**: The string to match.
* `pattern` **{String}**: Glob pattern to use for matching.
* `options` **{Object}**
* `returns` **{Boolean}**: Returns true if the patter matches any part of `str`.
### [.matcher](index.js#L196)
Takes an extglob pattern and returns a matcher function. The returned function takes the string to match as its only argument.
**Example**
```js
var extglob = require('extglob');
var isMatch = extglob.matcher('*.!(*a)');
console.log(isMatch('a.a'));
//=> false
console.log(isMatch('a.b'));
//=> true
```
**Params**
* `pattern` **{String}**: Extglob pattern
* `options` **{String}**
* `returns` **{Boolean}**
### [.create](index.js#L226)
Convert the given `extglob` pattern into a regex-compatible string. Returns an object with the compiled result and the parsed AST.
**Example**
```js
var extglob = require('extglob');
console.log(extglob.create('*.!(*a)').output);
//=> '(?!\\.)[^/]*?\\.(?!(?!\\.)[^/]*?a\\b).*?'
```
**Params**
* `str` **{String}**
* `options` **{Object}**
* `returns` **{String}**
### [.makeRe](index.js#L255)
Create a regular expression from the given `pattern` and `options`.
**Example**
```js
var extglob = require('extglob');
var re = extglob.makeRe('*.!(*a)');
console.log(re);
//=> /^[^\/]*?\.(?![^\/]*?a)[^\/]*?$/
```
**Params**
* `pattern` **{String}**: The pattern to convert to regex.
* `options` **{Object}**
* `returns` **{RegExp}**
## Options
Available options are based on the options from Bash (and the option names used in bash).
### options.nullglob
**Type**: `boolean`
**Default**: `undefined`
When enabled, the pattern itself will be returned when no matches are found.
### options.nonull
Alias for [options.nullglob](#optionsnullglob), included for parity with minimatch.
### options.cache
**Type**: `boolean`
**Default**: `undefined`
Functions are memoized based on the given glob patterns and options. Disable memoization by setting `options.cache` to false.
### options.failglob
**Type**: `boolean`
**Default**: `undefined`
Throw an error is no matches are found.
## Benchmarks
Last run on October 20, 2016
```sh
$ npm i -d && npm test
Benchmarking: (5 of 5)
· negation-nested
· negation-simple
· range-false
· range-true
· star-simple
# benchmark/fixtures/isMatch/negation-nested.js (49 bytes)
extglob x 1,988,591 ops/sec ±1.18% (84 runs sampled)
minimatch x 73,335 ops/sec ±1.38% (84 runs sampled)
fastest is extglob
# benchmark/fixtures/isMatch/negation-simple.js (43 bytes)
extglob x 2,320,380 ops/sec ±1.71% (86 runs sampled)
minimatch x 122,947 ops/sec ±1.28% (86 runs sampled)
fastest is extglob
# benchmark/fixtures/isMatch/range-false.js (56 bytes)
extglob x 1,729,572 ops/sec ±1.22% (84 runs sampled)
minimatch x 112,566 ops/sec ±1.26% (85 runs sampled)
fastest is extglob
# benchmark/fixtures/isMatch/range-true.js (56 bytes)
extglob x 1,819,085 ops/sec ±1.28% (83 runs sampled)
minimatch x 115,153 ops/sec ±1.50% (85 runs sampled)
fastest is extglob
# benchmark/fixtures/isMatch/star-simple.js (46 bytes)
extglob x 1,970,063 ops/sec ±1.46% (83 runs sampled)
minimatch x 138,805 ops/sec ±1.31% (87 runs sampled)
fastest is extglob
```
## Contributing
## Differences from Bash
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/extglob/issues/new)
This library has complete parity with Bash 4.3 with only a couple of minor differences.
## Author
* In some cases Bash returns true if the given string "contains" the pattern, whereas this library returns true if the string is an exact match for the pattern. You can relax this by setting `options.contains` to true.
* This library is more accurate than Bash and thus does not fail some of the tests that Bash 4.3 still lists as failing in their unit tests
## About
### Related projects
* [braces](https://www.npmjs.com/package/braces): Fastest brace expansion for node.js, with the most complete support for the Bash 4.3 braces… [more](https://github.com/jonschlinkert/braces) | [homepage](https://github.com/jonschlinkert/braces "Fastest brace expansion for node.js, with the most complete support for the Bash 4.3 braces specification.")
* [expand-brackets](https://www.npmjs.com/package/expand-brackets): Expand POSIX bracket expressions (character classes) in glob patterns. | [homepage](https://github.com/jonschlinkert/expand-brackets "Expand POSIX bracket expressions (character classes) in glob patterns.")
* [expand-range](https://www.npmjs.com/package/expand-range): Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See… [more](https://github.com/jonschlinkert/expand-range) | [homepage](https://github.com/jonschlinkert/expand-range "Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See the benchmarks. Used by micromatch.")
* [fill-range](https://www.npmjs.com/package/fill-range): Fill in a range of numbers or letters, optionally passing an increment or `step` to… [more](https://github.com/jonschlinkert/fill-range) | [homepage](https://github.com/jonschlinkert/fill-range "Fill in a range of numbers or letters, optionally passing an increment or `step` to use, or create a regex-compatible range with `options.toRegex`")
* [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).
### Contributors
| **Commits** | **Contributor**<br/> |
| --- | --- | --- | --- | --- |
| 32 | [jonschlinkert](https://github.com/jonschlinkert) |
| 2 | [isiahmeadows](https://github.com/isiahmeadows) |
| 1 | [shinnn](https://github.com/shinnn) |
### 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
Install dev dependencies:
```sh
$ npm install -d && npm test
```
### Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
### License
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT license](https://github.com/jonschlinkert/extglob/blob/master/LICENSE).
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 01, 2015._
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on October 20, 2016._
<hr class="footnotes-sep">
<section class="footnotes">
<ol class="footnotes-list">
<li id="fn1" class="footnote-item">`@` isn't a RegEx character. <a href="#fnref1" class="footnote-backref">↩</a>
</li>
</ol>
</section>

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc