Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
var braces = require('../..');
var mm = require('minimatch');
var text = require('text-table');
var Time = require('time-diff');
var time = new Time();
var table = [
['**Pattern**', '**braces**', '**minimatch**'],
['---', '---', '---']
];
// warm up both libs
mm.braceExpand('{a,b}');
braces('{a,b}');
function generate(pattern) {
time.start('braces');
var bval = braces(pattern, {rangeLimit: false}).join('|');
var b = [wrap(format(bval.length)), '(' + time.end('braces', 'μs') + ')'].join(' ');
time.start('minimatch');
var mval = mm.braceExpand(pattern).join('|');
var m = [wrap(format(mval.length)), '(' + time.end('minimatch', 'μs') + ')'].join(' ');
table.push([wrap(pattern), b, m]);
return table;
}
function wrap(str) {
function generate(pattern) {
time.start('braces');
var bval = braces(pattern, {rangeLimit: false}).join('|');
var b = [wrap(format(bval.length)), '(' + time.end('braces', 'μs') + ')'].join(' ');
time.start('minimatch');
var mval = mm.braceExpand(pattern).join('|');
var m = [wrap(format(mval.length)), '(' + time.end('minimatch', 'μs') + ')'].join(' ');
table.push([wrap(pattern), b, m]);
return table;
}
mm.braces = function(pattern, options) {
return minimatch.braceExpand(pattern, options);
};
mm.braces = function(pattern, options) {
return minimatch.braceExpand(pattern, options);
};
.add('minimatch', () => minimatch.braceExpand('foo/{a,b,c}/bar'))
.run();
.add('minimatch', () => minimatch.braceExpand('foo/{a,b,{x,y,z}}/bar'))
.run();
.add('minimatch', () => mm.braceExpand('foo/{a,b,{1..250}}/bar'))
.run();
.add('minimatch', () => mm.braceExpand('foo/{1..250}/bar'))
.run();
.add('minimatch', () => minimatch.braceExpand('foo/{a,b,{1..250}}/bar'))
.run();