diff --git a/examples/ast.js b/examples/ast.js deleted file mode 100644 index bfecbef..0000000 --- a/examples/ast.js +++ /dev/null @@ -1,20 +0,0 @@ -var braces = require('..'); - -var ast = braces.parse('a/{\\{b,c,d},z}/e', {unescape: false}); -var str = ''; -console.log(ast); - -visit(ast, function(node) { - if (node.val) str += node.val; -}); - -function visit(node, fn) { - return node.nodes ? mapVisit(node, fn) : fn(node); -} - -function mapVisit(node, fn) { - for (var i = 0; i < node.nodes.length; i++) { - visit(node.nodes[i], fn); - } - return node; -} diff --git a/examples/braces.js b/examples/braces.js deleted file mode 100644 index 9692522..0000000 --- a/examples/braces.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -var braces = require('..'); -// console.log(braces('some/path/{a,b,c}')); -// console.log(braces.expand('some/path/{a,b,c}')); - -var res = braces('{1..10000000}'); -console.log(res); -// console.log(format(res[0].length)); - -var res = braces('{1..100000000}'); -console.log(res); -// console.log(format(res[0].length)); diff --git a/examples/brackets.js b/examples/brackets.js deleted file mode 100644 index d37600b..0000000 --- a/examples/brackets.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var braces = require('..'); -var list = ['foo.js', '(a).js', '(b).js', '(c).js']; -console.log(braces.match(list, '{([a-b]),foo}.js')); -console.log(braces.expand('{([a-b]),foo}.js')); -console.log(braces.expand('{[dec-1992],[dec-1993]}.js')); diff --git a/examples/comparison.js b/examples/comparison.js deleted file mode 100644 index c3d1819..0000000 --- a/examples/comparison.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; - -var braceExpansion = require('brace-expansion'); -var braces = require('..'); - -console.log('braces'); -console.log(braces('http://any.org/archive{1996..1999}/vol({1..4})/part{a,b,c}.html')); -console.log(braces('http://any.org/archive{1996..1999}/vol{1..4}/part{a,b,c}.html')); -console.log(braces('http://www.numericals.com/file{1..100..10}.txt')); -console.log(braces('http://www.letters.com/file{a..z..2}.txt')); -console.log(braces('mkdir /usr/local/src/bash/{old,new,dist,bugs}')); -console.log(braces('chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}')); -console.log(); -console.log(); -console.log('braces: {expand: true}'); -console.log(braces('http://any.org/archive{1996..1999}/vol{1..4}/part{a,b,c}.html', {expand: true})); -console.log(braces('http://www.numericals.com/file{1..100..10}.txt', {expand: true})); -console.log(braces('http://www.letters.com/file{a..z..2}.txt', {expand: true})); -console.log(braces('mkdir /usr/local/src/bash/{old,new,dist,bugs}', {expand: true})); -console.log(braces('chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}', {expand: true})); -console.log(); -console.log(); -console.log('brace-expansion'); -console.log(braceExpansion('http://any.org/archive{1996..1999}/vol{1..4}/part{a,b,c}.html')); -console.log(braceExpansion('http://www.numericals.com/file{1..100..10}.txt')); -console.log(braceExpansion('http://www.letters.com/file{a..z..2}.txt')); -console.log(braceExpansion('mkdir /usr/local/src/bash/{old,new,dist,bugs}')); -console.log(braceExpansion('chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}')); - - -console.log(braces('user-{200..300}/project-{a,b,c}-{1..10}')) -//=> 'user-(20[0-9]|2[1-9][0-9]|300)/project-(a|b|c)-([1-9]|10)' -console.log(braces.makeRe('user-{200..300}')) -//=> /^(?:user-(20[0-9]|2[1-9][0-9]|300))$/ diff --git a/examples/escape.js b/examples/escape.js deleted file mode 100644 index c597ec2..0000000 --- a/examples/escape.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -var braces = require('..'); -console.log(braces.expand('{1\\.2}')); diff --git a/examples/expand.js b/examples/expand.js index 2acf235..8efaefc 100644 --- a/examples/expand.js +++ b/examples/expand.js @@ -1,14 +1,24 @@ -'use strict'; -var mm = require('minimatch'); -var braces = require('..'); +const colors = require('ansi-colors'); +const parse = require('./parse'); +const color = (arr, c) => arr.map(s => c(s)).join(', '); +const cp = require('child_process'); +const braces = input => { + return cp.execSync(`echo ${input}`).toString().trim().split(' '); +}; -console.log(braces.expand('a/{b,c}/d')); -//=> [ 'a/b/d', 'a/c/d' ] - -var ast = braces.parse('a{b{a,b}}c'); -var res = braces.compile(ast, {expand: true}); -console.log(res) - -console.log(braces.expand('{1..100}{1..100}').length); -console.log(braces.expand('{1..10}{1..10}{1..10}').length); +// const fixture = '{a,{b,c},d}'; +// const fixture = '{a,b}{c,d}{e,f}'; +// const fixture = 'a/{b,c{x,y}d,e}/f'; +// const fixture = '{{a,b}/i,j,k}'; +// const fixture = '{c,d{e,f}g,h}'; +// const fixture = '{{c,d{e,f}g,h}/i,j,k}'; +// const fixture = '{a,b}/{c,d{e,f}g,h}'; +// const fixture = '{{a,b}/{c,d{e,f}g,h}/i,j,k}'; +// const fixture = '{x,y,{a,b,c\\}}'; +const fixture = 'a{,b}c'; +console.log(); +console.log(' FIXTURE:', colors.magenta(fixture)); +console.log(' ACTUAL:', color(expand(parse(fixture)), colors.yellow)); +console.log('EXPECTED:', color(braces(fixture), colors.blue)); +console.log(); diff --git a/examples/extglobs.js b/examples/extglobs.js deleted file mode 100644 index 800889c..0000000 --- a/examples/extglobs.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var braces = require('..'); -console.log(braces.expand('{!(a|b),!(c|d)}')); -console.log(braces('{!(a|b),!(c|d)}')); diff --git a/examples/nested-regex.js b/examples/nested-regex.js deleted file mode 100644 index 6d6d532..0000000 --- a/examples/nested-regex.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var minimatch = require('minimatch'); -var braces = require('..'); - -console.log('braces'); -console.log(braces.makeRe('a{b,c{1..100}/{foo/bar},h}x/z')); -console.log(); -console.log(); -console.log('brace-expansion'); -console.log(minimatch.makeRe('a{b,c{1..100}/{foo/bar},h}x/z')); - diff --git a/examples/nested.js b/examples/nested.js deleted file mode 100644 index 3677928..0000000 --- a/examples/nested.js +++ /dev/null @@ -1,49 +0,0 @@ -var util = require('util'); -var braces = require('..').expand; -var expand = require('brace-expansion'); -var bash = require('../test/support/bash'); - -function log(pattern) { - // console.log('---'); - console.log('equal(\'' + pattern + '\', ', util.inspect(braces(pattern).sort()).split('\n').join('') + ');'); - // console.log('equal(\'' + pattern + '\', ', util.inspect(bash(pattern).sort()).split('\n').join('') + ');'); - // console.log('equal(\'' + pattern + '\', ', util.inspect(expand(pattern).sort()).split('\n').join('') + ');'); - // console.log(expand(pattern)); - console.log(); -} - -log('{,eno,thro,ro}ugh') -log('{,{,eno,thro,ro}ugh}{,out}') -log('{{,eno,thro,ro}ugh,}{,out}') -log('{,{,a,b}z}{,c}') -log('{,{,a,b}z}{c,}') -log('{,{,a,b}z}{,c,}') -log('{,{,a,b}z}{c,d}') -log('{{,a,b}z,}{,c}') -log('{,a{,b}z,}{,c}') -log('{,a{,b},}{,c}') -log('{,a{,b}}{,c}') -log('{,b}{,d}') -log('{a,b}{,d}') -log('{,a}{z,c}') -log('{,{,a},}{z,c}') -log('{,,a,}{z,c}') -log('{{,a},}{z,c}') -log('{,{,a},}{z,c}') -log('{,{,a}}{z,c}') -log('{{a,},}{z,c}') -log('{{,a},}{z,c}') -log('{,,a}{z,c}') -log('{,a,}{z,c}') -log('{,{,}}{z,c}') -log('{,{a,b}}{,c}') -log('{,{a,}}{,c}') -log('{,{,b}}{,c}') -log('{,{,}}{,c}') -log('{,a}{,c}') -log('{,{,a}b}') -log('{,b}') -log('{,b{,a}}') -log('{b,{,a}}') -log('{,b}{,d}') -log('{a,b}{,d}') diff --git a/examples/options.quantifiers.js b/examples/options.quantifiers.js deleted file mode 100644 index ff79a57..0000000 --- a/examples/options.quantifiers.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -var mm = require('minimatch'); -var braces = require('..'); - -/** - * True - */ - -console.log(braces('a/b{1,3}/{x,y,z}', {quantifiers: true})); -//=> [ 'a/b(1|3)/(x|y|z)' ] -console.log(braces('a/b{1,3}/{x,y,z}', {quantifiers: true})); -//=> [ 'a/b{1,3}/(x|y|z)' ] -console.log(braces('a/b{1,3}/{x,y,z}', {quantifiers: true, expand: true})); -//=> [ 'a/b{1,3}/x', 'a/b{1,3}/y', 'a/b{1,3}/z' ] - -/** - * False - */ - -console.log(braces('a/b{1,3}/{x,y,z}', {quantifiers: false})); -//=> [ 'a/b(1|3)/(x|y|z)' ] -console.log(braces('a/b{1,3}/{x,y,z}', {quantifiers: false})); -//=> [ 'a/b{1,3}/(x|y|z)' ] -console.log(braces('a/b{1,3}/{x,y,z}', {quantifiers: false, expand: true})); -//=> [ 'a/b{1,3}/x', 'a/b{1,3}/y', 'a/b{1,3}/z' ] diff --git a/examples/parse.js b/examples/parse.js new file mode 100644 index 0000000..1adf666 --- /dev/null +++ b/examples/parse.js @@ -0,0 +1,25 @@ +'use strict'; + +// const input = 'foo/{a,bar/{b,c},d}'; +// const input = 'a/{b,c{x,y}}/d'; +// const input = '{{x,y},/{b,c{x,y}d,e}/f}'; +// const input = '{{a,b}/{b,c{x,y}d,e}/f,x,z}'; +// const input = 'a/{b,c}/d'; +// const ast = parse(input); +// console.log(ast) +// console.log(JSON.stringify(ast.queue)); +// console.log('EXPECTED:', [ 'a/b/f', 'a/cxd/f', 'a/cyd/f', 'a/e/f' ]); +// console.log(JSON.stringify(ast, null, 2)) +// console.log(expand(ast)); +// expand(ast); + +// const sets = parse('foo/{a/b,{c,d,{x..z},e},f}/bar'); +// const sets = parse('{a,{c,d}'); +// console.log(sets.nodes[2]); +// console.log(compile(sets)); + +// const range = parse(']{a..e,z}'); +// console.log(range.nodes[2]); +// console.log(braces.expand(']{a..e,z}')) +// console.log(compile(range)); +// console.log(parse('[abc]')) diff --git a/examples/paths.js b/examples/paths.js deleted file mode 100644 index b759bb8..0000000 --- a/examples/paths.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -var braces = require('..'); - -console.log(braces('foo*{/*,*}')); -console.log(braces('foo (abc, 1990)')); diff --git a/examples/readme.js b/examples/readme.js deleted file mode 100644 index 53131a7..0000000 --- a/examples/readme.js +++ /dev/null @@ -1,28 +0,0 @@ -var braces = require('..'); - -console.log(braces.expand('it{,{{em,alic}iz,erat}e{d,}}')); -console.log(braces.expand('I like {pizza,beer,money}.')); -// console.log(braces.expand('{bull,shoe}{,horn}')); - -console.log(braces.expand('{a,b}{1,2}')); -//=> [ 'a1', 'a2', 'b1', 'b2' ] - -console.log(braces.expand('{a,b}/{1,2}')); -//=> [ 'a/1', 'a/2', 'b/1', 'b/2' ] - -console.log(braces.expand('foo/{a,b,c}/bar').join(' ')); -console.log(braces('{a,b}{1,2}')); -//=> [ '(a|b)(1|2)' ] - -console.log(braces.expand('{a,b,c}{1,2}').join(' ')); -console.log(braces.expand('{4..-4}').join(' ')); -//=> [ '(a|b)/(1|2)' ] - -console.log(braces.expand('{a,b,c}{1..3}').join(' ')); -console.log(braces.expand('{a..j}').join(' ')); -console.log(braces.expand('{j..a}').join(' ')); -console.log(braces.expand('{1..20..3}').join(' ')); -console.log(braces.expand('{a..z..3}').join(' ')); -console.log(braces.expand('a{1..3}b').join(' ')); -console.log(braces.expand('{1..3}.{0..9}0')); -//=> [ 'a1b', 'a2b', 'a3b' ] diff --git a/examples/regex.js b/examples/regex.js deleted file mode 100644 index 711e8e2..0000000 --- a/examples/regex.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -var mm = require('minimatch'); -var braces = require('..'); - -// console.log(braces.makeRe('a/b/c/{k,l,m}/d/{w,x,y,z}/d/e', {expand: true})); -// console.log(mm.makeRe('a/b/c/{k,l,m}/d/{w,x,y,z}/d/e')); - -// console.log('braces.makeRe: "foo/{1..20000}/bar/{a..j}/baz"'); -// console.log(braces.makeRe('foo/{1..20000}/bar/{a..j}/baz')); -// console.log(); -// console.log('minimatch.makeRe: "foo/{1..20000}/bar/{a..j}/baz"'); -// console.log(mm.makeRe('foo/{1..20000}/bar/{a..j}/baz')); - -// var re = braces.makeRe('a/{foo/bar}/z'); -// console.log(re); -// console.log(re.test('a/{foo/bar}/z')); - -console.log(braces.makeRe('{00000001..99999999}')); diff --git a/examples/sequences-steps.js b/examples/sequences-steps.js deleted file mode 100644 index 6895aa9..0000000 --- a/examples/sequences-steps.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var mm = require('minimatch'); -var braces = require('..'); - -console.log(braces('{0..10..2}', {expand: true})); -//=> [ '0', '2', '4', '6', '8', '10' ] diff --git a/examples/sequences.js b/examples/sequences.js deleted file mode 100644 index 88dcf88..0000000 --- a/examples/sequences.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var mm = require('minimatch'); -var braces = require('..'); - -console.log(braces('{1..5}', {expand: true})); -//=> [ '1', '2', '3', '4', '5' ] - -console.log(braces('{"1..5"}', {expand: true}))