expand-brackets
Advanced tools
Comparing version 3.0.0 to 4.0.0
## Changelog | ||
### v4.0.0 | ||
**Breaking changes** | ||
- Snapdragon was updated to 0.12. Other packages that integrate `expand-brackets` need to also use snapdragon 0.12. | ||
- Minimum Node.JS version is now version 4. | ||
### v3.0.0 | ||
@@ -4,0 +11,0 @@ |
55
index.js
@@ -7,4 +7,4 @@ 'use strict'; | ||
var compilers = require('./lib/compilers'); | ||
var parsers = require('./lib/parsers'); | ||
const compilers = require('./lib/compilers'); | ||
const parsers = require('./lib/parsers'); | ||
@@ -15,5 +15,4 @@ /** | ||
var extend = require('extend-shallow'); | ||
var Snapdragon = require('snapdragon'); | ||
var toRegex = require('to-regex'); | ||
const Snapdragon = require('snapdragon'); | ||
const toRegex = require('to-regex'); | ||
@@ -31,3 +30,3 @@ /** | ||
function brackets(pattern, options) { | ||
var res = brackets.create(pattern, options); | ||
const res = brackets.create(pattern, options); | ||
return res.output; | ||
@@ -41,3 +40,3 @@ } | ||
* ```js | ||
* var brackets = require('expand-brackets'); | ||
* const brackets = require('expand-brackets'); | ||
* console.log(brackets.match(['1', 'a', 'ab'], '[[:alpha:]]')); | ||
@@ -58,10 +57,10 @@ * //=> ['a'] | ||
arr = [].concat(arr); | ||
var opts = extend({}, options); | ||
var isMatch = brackets.matcher(pattern, opts); | ||
var len = arr.length; | ||
var idx = -1; | ||
var res = []; | ||
const opts = Object.assign({}, options); | ||
const isMatch = brackets.matcher(pattern, opts); | ||
const len = arr.length; | ||
const res = []; | ||
let idx = -1; | ||
while (++idx < len) { | ||
var ele = arr[idx]; | ||
const ele = arr[idx]; | ||
if (isMatch(ele)) { | ||
@@ -74,3 +73,3 @@ res.push(ele); | ||
if (opts.failglob === true) { | ||
throw new Error('no matches found for "' + pattern + '"'); | ||
throw new Error(`no matches found for "${pattern}"`); | ||
} | ||
@@ -90,3 +89,3 @@ | ||
* ```js | ||
* var brackets = require('expand-brackets'); | ||
* const brackets = require('expand-brackets'); | ||
* | ||
@@ -114,4 +113,4 @@ * console.log(brackets.isMatch('a.a', '[[:alpha:]].[[:alpha:]]')); | ||
* ```js | ||
* var brackets = require('expand-brackets'); | ||
* var isMatch = brackets.matcher('[[:lower:]].[[:upper:]]'); | ||
* const brackets = require('expand-brackets'); | ||
* const isMatch = brackets.matcher('[[:lower:]].[[:upper:]]'); | ||
* | ||
@@ -130,6 +129,4 @@ * console.log(isMatch('a.a')); | ||
brackets.matcher = function(pattern, options) { | ||
var re = brackets.makeRe(pattern, options); | ||
return function(str) { | ||
return re.test(str); | ||
}; | ||
const re = brackets.makeRe(pattern, options); | ||
return (str) => re.test(str); | ||
}; | ||
@@ -141,4 +138,4 @@ | ||
* ```js | ||
* var brackets = require('expand-brackets'); | ||
* var re = brackets.makeRe('[[:alpha:]]'); | ||
* const brackets = require('expand-brackets'); | ||
* const re = brackets.makeRe('[[:alpha:]]'); | ||
* console.log(re); | ||
@@ -154,4 +151,4 @@ * //=> /^(?:[a-zA-Z])$/ | ||
brackets.makeRe = function(pattern, options) { | ||
var res = brackets.create(pattern, options); | ||
var opts = extend({strictErrors: false}, options); | ||
const res = brackets.create(pattern, options); | ||
const opts = Object.assign({strictErrors: false}, options); | ||
return toRegex(res.output, opts); | ||
@@ -165,3 +162,3 @@ }; | ||
* ```js | ||
* var brackets = require('expand-brackets'); | ||
* const brackets = require('expand-brackets'); | ||
* console.log(brackets('[[:alpha:]]')); | ||
@@ -198,9 +195,9 @@ * // { options: { source: 'string' }, | ||
brackets.create = function(pattern, options) { | ||
var snapdragon = (options && options.snapdragon) || new Snapdragon(options); | ||
const snapdragon = (options && options.snapdragon) || new Snapdragon(options); | ||
compilers(snapdragon); | ||
parsers(snapdragon); | ||
var ast = snapdragon.parse(pattern, options); | ||
const ast = snapdragon.parse(pattern, options); | ||
ast.input = pattern; | ||
var res = snapdragon.compile(ast, options); | ||
const res = snapdragon.compile(ast, options); | ||
res.input = pattern; | ||
@@ -207,0 +204,0 @@ return res; |
'use strict'; | ||
var posix = require('posix-character-classes'); | ||
const posix = require('posix-character-classes'); | ||
@@ -33,3 +33,3 @@ module.exports = function(brackets) { | ||
var val = posix[node.inner]; | ||
let val = posix[node.inner]; | ||
if (typeof val === 'undefined') { | ||
@@ -52,3 +52,3 @@ val = '[' + node.inner + ']'; | ||
.set('bracket.inner', function(node) { | ||
var inner = node.val; | ||
let inner = node.val; | ||
@@ -69,3 +69,3 @@ if (inner === '[' || inner === ']') { | ||
var isNegated = inner.charAt(0) === '^'; | ||
const isNegated = inner.charAt(0) === '^'; | ||
// add slashes to negated brackets, per spec | ||
@@ -84,3 +84,3 @@ if (isNegated && inner.indexOf('/') === -1) { | ||
.set('bracket.close', function(node) { | ||
var val = node.val.replace(/^\\/, ''); | ||
const val = node.val.replace(/^\\/, ''); | ||
if (node.parent.escaped === true) { | ||
@@ -87,0 +87,0 @@ return this.emit('\\' + val, node); |
'use strict'; | ||
var utils = require('./utils'); | ||
const utils = require('./utils'); | ||
@@ -9,4 +9,4 @@ /** | ||
var TEXT_REGEX = '(\\[(?=.*\\])|\\])+'; | ||
var not = utils.createRegex(TEXT_REGEX); | ||
const TEXT_REGEX = '(\\[(?=.*\\])|\\])+'; | ||
const not = utils.createRegex(TEXT_REGEX); | ||
@@ -24,4 +24,4 @@ /** | ||
if (this.isInside('bracket')) return; | ||
var pos = this.position(); | ||
var m = this.match(/^\\(.)/); | ||
const pos = this.position(); | ||
const m = this.match(/^\\(.)/); | ||
if (!m) return; | ||
@@ -41,4 +41,4 @@ | ||
if (this.isInside('bracket')) return; | ||
var pos = this.position(); | ||
var m = this.match(not); | ||
const pos = this.position(); | ||
const m = this.match(not); | ||
if (!m || !m[0]) return; | ||
@@ -57,4 +57,4 @@ | ||
.set('posix', function() { | ||
var pos = this.position(); | ||
var m = this.match(/^\[:(.*?):\](?=.*\])/); | ||
const pos = this.position(); | ||
const m = this.match(/^\[:(.*?):\](?=.*\])/); | ||
if (!m) return; | ||
@@ -86,9 +86,9 @@ | ||
.set('bracket.open', function() { | ||
var parsed = this.parsed; | ||
var pos = this.position(); | ||
var m = this.match(/^\[(?=.*\])/); | ||
const parsed = this.parsed; | ||
const pos = this.position(); | ||
const m = this.match(/^\[(?=.*\])/); | ||
if (!m) return; | ||
var prev = this.prev(); | ||
var last = utils.last(prev.nodes); | ||
const prev = this.prev(); | ||
const last = utils.last(prev.nodes); | ||
@@ -103,3 +103,3 @@ if (parsed.slice(-1) === '\\' && !this.isInside('bracket')) { | ||
var open = pos({ | ||
const open = pos({ | ||
type: 'bracket.open', | ||
@@ -116,3 +116,3 @@ val: m[0] | ||
var node = pos({ | ||
const node = pos({ | ||
type: 'bracket', | ||
@@ -133,12 +133,12 @@ nodes: [] | ||
if (!this.isInside('bracket')) return; | ||
var pos = this.position(); | ||
var m = this.match(not); | ||
const pos = this.position(); | ||
const m = this.match(not); | ||
if (!m || !m[0]) return; | ||
var next = this.input.charAt(0); | ||
var val = m[0]; | ||
const next = this.input.charAt(0); | ||
let val = m[0]; | ||
var node = pos({ | ||
const node = pos({ | ||
type: 'bracket.inner', | ||
val: val | ||
val | ||
}); | ||
@@ -150,4 +150,4 @@ | ||
var first = val.charAt(0); | ||
var last = val.slice(-1); | ||
const first = val.charAt(0); | ||
const last = val.slice(-1); | ||
@@ -172,9 +172,9 @@ if (first === '!') { | ||
.set('bracket.close', function() { | ||
var parsed = this.parsed; | ||
var pos = this.position(); | ||
var m = this.match(/^\]/); | ||
const parsed = this.parsed; | ||
const pos = this.position(); | ||
const m = this.match(/^\]/); | ||
if (!m) return; | ||
var prev = this.prev(); | ||
var last = utils.last(prev.nodes); | ||
const prev = this.prev(); | ||
const last = utils.last(prev.nodes); | ||
@@ -190,3 +190,3 @@ if (parsed.slice(-1) === '\\' && !this.isInside('bracket')) { | ||
var node = pos({ | ||
const node = pos({ | ||
type: 'bracket.close', | ||
@@ -203,3 +203,3 @@ rest: this.input, | ||
var bracket = this.pop('bracket'); | ||
const bracket = this.pop('bracket'); | ||
if (!this.isType(bracket, 'bracket')) { | ||
@@ -206,0 +206,0 @@ if (this.options.strict) { |
'use strict'; | ||
var toRegex = require('to-regex'); | ||
var regexNot = require('regex-not'); | ||
var cached; | ||
const toRegex = require('to-regex'); | ||
const regexNot = require('regex-not'); | ||
let cached; | ||
@@ -23,5 +23,5 @@ /** | ||
if (cached) return cached; | ||
var opts = {contains: true, strictClose: false}; | ||
var not = regexNot.create(pattern, opts); | ||
var re; | ||
const opts = {contains: true, strictClose: false}; | ||
const not = regexNot.create(pattern, opts); | ||
let re; | ||
@@ -28,0 +28,0 @@ if (typeof include === 'string') { |
{ | ||
"name": "expand-brackets", | ||
"description": "Expand POSIX bracket expressions (character classes) in glob patterns.", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"homepage": "https://github.com/micromatch/expand-brackets", | ||
@@ -24,3 +24,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=4.0.0" | ||
}, | ||
@@ -31,16 +31,15 @@ "scripts": { | ||
"dependencies": { | ||
"extend-shallow": "^3.0.2", | ||
"posix-character-classes": "^1.0.0", | ||
"regex-not": "^1.0.0", | ||
"snapdragon": "^0.11.3", | ||
"snapdragon": "^0.12.0", | ||
"to-regex": "^3.0.1" | ||
}, | ||
"devDependencies": { | ||
"bash-match": "^0.1.1", | ||
"gulp-format-md": "^0.1.10", | ||
"bash-match": "^1.0.2", | ||
"gulp-format-md": "^1.0.0", | ||
"helper-changelog": "^0.3.0", | ||
"minimatch": "^3.0.3", | ||
"mocha": "^3.0.2", | ||
"mocha": "^5.1.1", | ||
"multimatch": "^2.1.0", | ||
"yargs-parser": "^4.0.0" | ||
"yargs-parser": "^10.0.0" | ||
}, | ||
@@ -47,0 +46,0 @@ "keywords": [ |
@@ -43,3 +43,3 @@ # expand-brackets [![NPM version](https://img.shields.io/npm/v/expand-brackets.svg?style=flat)](https://www.npmjs.com/package/expand-brackets) [![NPM monthly downloads](https://img.shields.io/npm/dm/expand-brackets.svg?style=flat)](https://npmjs.org/package/expand-brackets) [![NPM total downloads](https://img.shields.io/npm/dt/expand-brackets.svg?style=flat)](https://npmjs.org/package/expand-brackets) [![Linux Build Status](https://img.shields.io/travis/micromatch/expand-brackets.svg?style=flat&label=Travis)](https://travis-ci.org/micromatch/expand-brackets) [![Windows Build Status](https://img.shields.io/appveyor/ci/micromatch/expand-brackets.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/micromatch/expand-brackets) | ||
### [brackets](index.js#L28) | ||
### [brackets](index.js#L27) | ||
@@ -55,3 +55,3 @@ Parses the given POSIX character class `pattern` and returns a | ||
### [.match](index.js#L52) | ||
### [.match](index.js#L51) | ||
@@ -70,3 +70,3 @@ Takes an array of strings and a POSIX character class pattern, and returns a new array with only the strings that matched the pattern. | ||
```js | ||
var brackets = require('expand-brackets'); | ||
const brackets = require('expand-brackets'); | ||
console.log(brackets.match(['1', 'a', 'ab'], '[[:alpha:]]')); | ||
@@ -79,3 +79,3 @@ //=> ['a'] | ||
### [.isMatch](index.js#L98) | ||
### [.isMatch](index.js#L97) | ||
@@ -94,3 +94,3 @@ Returns true if the specified `string` matches the given brackets `pattern`. | ||
```js | ||
var brackets = require('expand-brackets'); | ||
const brackets = require('expand-brackets'); | ||
@@ -103,3 +103,3 @@ console.log(brackets.isMatch('a.a', '[[:alpha:]].[[:alpha:]]')); | ||
### [.matcher](index.js#L121) | ||
### [.matcher](index.js#L120) | ||
@@ -117,4 +117,4 @@ Takes a POSIX character class pattern and returns a matcher function. The returned function takes the string to match as its only argument. | ||
```js | ||
var brackets = require('expand-brackets'); | ||
var isMatch = brackets.matcher('[[:lower:]].[[:upper:]]'); | ||
const brackets = require('expand-brackets'); | ||
const isMatch = brackets.matcher('[[:lower:]].[[:upper:]]'); | ||
@@ -127,3 +127,3 @@ console.log(isMatch('a.a')); | ||
### [.makeRe](index.js#L143) | ||
### [.makeRe](index.js#L140) | ||
@@ -141,4 +141,4 @@ Create a regular expression from the given `pattern`. | ||
```js | ||
var brackets = require('expand-brackets'); | ||
var re = brackets.makeRe('[[:alpha:]]'); | ||
const brackets = require('expand-brackets'); | ||
const re = brackets.makeRe('[[:alpha:]]'); | ||
console.log(re); | ||
@@ -148,3 +148,3 @@ //=> /^(?:[a-zA-Z])$/ | ||
### [.create](index.js#L185) | ||
### [.create](index.js#L182) | ||
@@ -162,3 +162,3 @@ Parses the given POSIX character class `pattern` and returns an object with the compiled `output` and optional source `map`. | ||
```js | ||
var brackets = require('expand-brackets'); | ||
const brackets = require('expand-brackets'); | ||
console.log(brackets('[[:alpha:]]')); | ||
@@ -231,2 +231,15 @@ // { options: { source: 'string' }, | ||
### v4.0.0 | ||
**Breaking changes** | ||
* Snapdragon was updated to 0.12. Other packages that integrate `expand-brackets` need to also use snapdragon 0.12. | ||
* Minimum Node.JS version is now version 4. | ||
### v3.0.0 | ||
**Breaking changes** | ||
* Snapdragon was updated to 0.11. Other packages that integrate `expand-brackets` need to also use snapdragon 0.11. | ||
### v2.0.0 | ||
@@ -284,3 +297,3 @@ | ||
| 69 | [jonschlinkert](https://github.com/jonschlinkert) | | ||
| 3 | [danez](https://github.com/danez) | | ||
| 13 | [danez](https://github.com/danez) | | ||
| 2 | [MartinKolarik](https://github.com/MartinKolarik) | | ||
@@ -324,2 +337,2 @@ | 2 | [es128](https://github.com/es128) | | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on March 25, 2018._ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on April 30, 2018._ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
26662
4
324
0
451
+ Addedkind-of@6.0.3(transitive)
+ Addedsnapdragon@0.12.1(transitive)
+ Addedsnapdragon-util@4.0.0(transitive)
+ Addedsource-map-resolve@0.6.0(transitive)
- Removedextend-shallow@^3.0.2
- Removeddebug@2.6.9(transitive)
- Removedextend-shallow@2.0.1(transitive)
- Removedis-extendable@0.1.1(transitive)
- Removedms@2.0.0(transitive)
- Removedresolve-url@0.2.1(transitive)
- Removedsnapdragon@0.11.5(transitive)
- Removedsnapdragon-util@2.1.1(transitive)
- Removedsource-map-resolve@0.5.3(transitive)
- Removedsource-map-url@0.4.1(transitive)
- Removedurix@0.1.0(transitive)
Updatedsnapdragon@^0.12.0