Skip to content

Commit

Permalink
cover sets
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschlinkert committed Apr 1, 2019
1 parent f5bf204 commit ceef790
Show file tree
Hide file tree
Showing 15 changed files with 781 additions and 935 deletions.
318 changes: 0 additions & 318 deletions backup.js

This file was deleted.

10 changes: 5 additions & 5 deletions bench/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,26 @@ bench.skip = name => {
};

bench('parse set')
.add('picomatch', () => parse('foo/{a,b,c}/bar'))
.add(' braces', () => parse('foo/{a,b,c}/bar'))
.add('minimatch', () => minimatch.braceExpand('foo/{a,b,c}/bar'))
.run();

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

bench('parse range')
.add('picomatch', () => parse('foo/{a..z}/bar'))
.add(' braces', () => parse('foo/{a..z}/bar'))
.add('minimatch', () => minimatch.braceExpand('foo/{a..z}/bar'))
.run();

bench.skip('expand')
.add('picomatch', () => expand(parse('foo/{a,b,c}/bar')))
.add(' braces', () => expand(parse('foo/{a,b,c}/bar')))
.add('minimatch', () => minimatch.braceExpand('foo/{a,b,c}/bar'))
.run();

bench.skip('compile')
.add('picomatch', () => compile(parse('foo/{a,b,c}/bar')))
.add(' braces', () => compile(parse('foo/{a,b,c}/bar')))
.add('minimatch', () => minimatch.makeRe('foo/{a,b,c}/bar'))
.run();
12 changes: 10 additions & 2 deletions lib/compile.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
'use strict';

const utils = require('./utils');

module.exports = (ast, options = {}) => {
let compile = node => {
let compile = (node, parent = {}) => {
let invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
let invalidNode = node.invalid === true && options.escapeInvalid === true;
let output = '';

if (node.value) {
if ((invalidBlock || invalidNode) && utils.isOpenOrClose(node)) {
return '\\' + node.value;
}
return node.value;
}

if (node.nodes) {
for (let child of node.nodes) {
output += compile(child);
output += compile(child, node);
}
}
return output;
Expand Down
5 changes: 3 additions & 2 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@ module.exports = {
// Non-alphabetic chars.
CHAR_AMPERSAND: '&', /* & */
CHAR_AT: '@', /* @ */
CHAR_BACKWARD_SLASH: '\\', /* \ */
CHAR_BACKSLASH: '\\', /* \ */
CHAR_BACKTICK: '`', /* ` */
CHAR_CARRIAGE_RETURN: '\r', /* \r */
CHAR_CIRCUMFLEX_ACCENT: '^', /* ^ */
CHAR_COLON: ':', /* : */
CHAR_COMMA: ',', /* , */
CHAR_DOLLAR: '$', /* . */
CHAR_DOT: '.', /* . */
CHAR_DOUBLE_QUOTE: '"', /* " */
CHAR_EQUAL: '=', /* = */
CHAR_EXCLAMATION_MARK: '!', /* ! */
CHAR_FORM_FEED: '\f', /* \f */
CHAR_FORWARD_SLASH: '/', /* / */
CHAR_GRAVE_ACCENT: '`', /* ` */
CHAR_HASH: '#', /* # */
CHAR_HYPHEN_MINUS: '-', /* - */
CHAR_LEFT_ANGLE_BRACKET: '<', /* < */
Expand Down
Loading

0 comments on commit ceef790

Please sign in to comment.