Skip to content

Commit ceef790

Browse files
committed
cover sets
1 parent f5bf204 commit ceef790

15 files changed

+781
-935
lines changed

backup.js

-318
This file was deleted.

bench/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,26 @@ bench.skip = name => {
5353
};
5454

5555
bench('parse set')
56-
.add('picomatch', () => parse('foo/{a,b,c}/bar'))
56+
.add(' braces', () => parse('foo/{a,b,c}/bar'))
5757
.add('minimatch', () => minimatch.braceExpand('foo/{a,b,c}/bar'))
5858
.run();
5959

6060
bench('parse nested sets')
61-
.add('picomatch', () => parse('foo/{a,b,{x,y,z}}/bar'))
61+
.add(' braces', () => parse('foo/{a,b,{x,y,z}}/bar'))
6262
.add('minimatch', () => minimatch.braceExpand('foo/{a,b,{x,y,z}}/bar'))
6363
.run();
6464

6565
bench('parse range')
66-
.add('picomatch', () => parse('foo/{a..z}/bar'))
66+
.add(' braces', () => parse('foo/{a..z}/bar'))
6767
.add('minimatch', () => minimatch.braceExpand('foo/{a..z}/bar'))
6868
.run();
6969

7070
bench.skip('expand')
71-
.add('picomatch', () => expand(parse('foo/{a,b,c}/bar')))
71+
.add(' braces', () => expand(parse('foo/{a,b,c}/bar')))
7272
.add('minimatch', () => minimatch.braceExpand('foo/{a,b,c}/bar'))
7373
.run();
7474

7575
bench.skip('compile')
76-
.add('picomatch', () => compile(parse('foo/{a,b,c}/bar')))
76+
.add(' braces', () => compile(parse('foo/{a,b,c}/bar')))
7777
.add('minimatch', () => minimatch.makeRe('foo/{a,b,c}/bar'))
7878
.run();

lib/compile.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
'use strict';
22

3+
const utils = require('./utils');
4+
35
module.exports = (ast, options = {}) => {
4-
let compile = node => {
6+
let compile = (node, parent = {}) => {
7+
let invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
8+
let invalidNode = node.invalid === true && options.escapeInvalid === true;
59
let output = '';
10+
611
if (node.value) {
12+
if ((invalidBlock || invalidNode) && utils.isOpenOrClose(node)) {
13+
return '\\' + node.value;
14+
}
715
return node.value;
816
}
917

1018
if (node.nodes) {
1119
for (let child of node.nodes) {
12-
output += compile(child);
20+
output += compile(child, node);
1321
}
1422
}
1523
return output;

lib/constants.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,19 @@ module.exports = {
2424
// Non-alphabetic chars.
2525
CHAR_AMPERSAND: '&', /* & */
2626
CHAR_AT: '@', /* @ */
27-
CHAR_BACKWARD_SLASH: '\\', /* \ */
27+
CHAR_BACKSLASH: '\\', /* \ */
28+
CHAR_BACKTICK: '`', /* ` */
2829
CHAR_CARRIAGE_RETURN: '\r', /* \r */
2930
CHAR_CIRCUMFLEX_ACCENT: '^', /* ^ */
3031
CHAR_COLON: ':', /* : */
3132
CHAR_COMMA: ',', /* , */
33+
CHAR_DOLLAR: '$', /* . */
3234
CHAR_DOT: '.', /* . */
3335
CHAR_DOUBLE_QUOTE: '"', /* " */
3436
CHAR_EQUAL: '=', /* = */
3537
CHAR_EXCLAMATION_MARK: '!', /* ! */
3638
CHAR_FORM_FEED: '\f', /* \f */
3739
CHAR_FORWARD_SLASH: '/', /* / */
38-
CHAR_GRAVE_ACCENT: '`', /* ` */
3940
CHAR_HASH: '#', /* # */
4041
CHAR_HYPHEN_MINUS: '-', /* - */
4142
CHAR_LEFT_ANGLE_BRACKET: '<', /* < */

0 commit comments

Comments
 (0)