pax_global_header00006660000000000000000000000064131174402040014506gustar00rootroot0000000000000052 comment=8f59e68bd5c915a0d624e8e39354e1ccf672edf6 brace-expansion-1.1.8/000077500000000000000000000000001311744020400145735ustar00rootroot00000000000000brace-expansion-1.1.8/.gitignore000066400000000000000000000000231311744020400165560ustar00rootroot00000000000000node_modules *.sw* brace-expansion-1.1.8/.npmignore000066400000000000000000000000621311744020400165700ustar00rootroot00000000000000test .gitignore .travis.yml example.js .npmignore brace-expansion-1.1.8/.travis.yml000066400000000000000000000001121311744020400166760ustar00rootroot00000000000000sudo: false language: node_js node_js: - "0.12" - "4" - "6" - "7" brace-expansion-1.1.8/README.md000066400000000000000000000071111311744020400160520ustar00rootroot00000000000000# brace-expansion [Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html), as known from sh/bash, in JavaScript. [![build status](https://secure.travis-ci.org/juliangruber/brace-expansion.svg)](http://travis-ci.org/juliangruber/brace-expansion) [![downloads](https://img.shields.io/npm/dm/brace-expansion.svg)](https://www.npmjs.org/package/brace-expansion) [![Greenkeeper badge](https://badges.greenkeeper.io/juliangruber/brace-expansion.svg)](https://greenkeeper.io/) [![testling badge](https://ci.testling.com/juliangruber/brace-expansion.png)](https://ci.testling.com/juliangruber/brace-expansion) ## Example ```js var expand = require('brace-expansion'); expand('file-{a,b,c}.jpg') // => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg'] expand('-v{,,}') // => ['-v', '-v', '-v'] expand('file{0..2}.jpg') // => ['file0.jpg', 'file1.jpg', 'file2.jpg'] expand('file-{a..c}.jpg') // => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg'] expand('file{2..0}.jpg') // => ['file2.jpg', 'file1.jpg', 'file0.jpg'] expand('file{0..4..2}.jpg') // => ['file0.jpg', 'file2.jpg', 'file4.jpg'] expand('file-{a..e..2}.jpg') // => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg'] expand('file{00..10..5}.jpg') // => ['file00.jpg', 'file05.jpg', 'file10.jpg'] expand('{{A..C},{a..c}}') // => ['A', 'B', 'C', 'a', 'b', 'c'] expand('ppp{,config,oe{,conf}}') // => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf'] ``` ## API ```js var expand = require('brace-expansion'); ``` ### var expanded = expand(str) Return an array of all possible and valid expansions of `str`. If none are found, `[str]` is returned. Valid expansions are: ```js /^(.*,)+(.+)?$/ // {a,b,...} ``` A comma seperated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`. ```js /^-?\d+\.\.-?\d+(\.\.-?\d+)?$/ // {x..y[..incr]} ``` A numeric sequence from `x` to `y` inclusive, with optional increment. If `x` or `y` start with a leading `0`, all the numbers will be padded to have equal length. Negative numbers and backwards iteration work too. ```js /^-?\d+\.\.-?\d+(\.\.-?\d+)?$/ // {x..y[..incr]} ``` An alphabetic sequence from `x` to `y` inclusive, with optional increment. `x` and `y` must be exactly one character, and if given, `incr` must be a number. For compatibility reasons, the string `${` is not eligible for brace expansion. ## Installation With [npm](https://npmjs.org) do: ```bash npm install brace-expansion ``` ## Contributors - [Julian Gruber](https://github.com/juliangruber) - [Isaac Z. Schlueter](https://github.com/isaacs) ## License (MIT) Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. brace-expansion-1.1.8/example.js000066400000000000000000000006161311744020400165670ustar00rootroot00000000000000var expand = require('./'); console.log(expand('http://any.org/archive{1996..1999}/vol{1..4}/part{a,b,c}.html')); console.log(expand('http://www.numericals.com/file{1..100..10}.txt')); console.log(expand('http://www.letters.com/file{a..z..2}.txt')); console.log(expand('mkdir /usr/local/src/bash/{old,new,dist,bugs}')); console.log(expand('chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}')); brace-expansion-1.1.8/index.js000066400000000000000000000112701311744020400162410ustar00rootroot00000000000000var concatMap = require('concat-map'); var balanced = require('balanced-match'); module.exports = expandTop; var escSlash = '\0SLASH'+Math.random()+'\0'; var escOpen = '\0OPEN'+Math.random()+'\0'; var escClose = '\0CLOSE'+Math.random()+'\0'; var escComma = '\0COMMA'+Math.random()+'\0'; var escPeriod = '\0PERIOD'+Math.random()+'\0'; function numeric(str) { return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0); } function escapeBraces(str) { return str.split('\\\\').join(escSlash) .split('\\{').join(escOpen) .split('\\}').join(escClose) .split('\\,').join(escComma) .split('\\.').join(escPeriod); } function unescapeBraces(str) { return str.split(escSlash).join('\\') .split(escOpen).join('{') .split(escClose).join('}') .split(escComma).join(',') .split(escPeriod).join('.'); } // Basically just str.split(","), but handling cases // where we have nested braced sections, which should be // treated as individual members, like {a,{b,c},d} function parseCommaParts(str) { if (!str) return ['']; var parts = []; var m = balanced('{', '}', str); if (!m) return str.split(','); var pre = m.pre; var body = m.body; var post = m.post; var p = pre.split(','); p[p.length-1] += '{' + body + '}'; var postParts = parseCommaParts(post); if (post.length) { p[p.length-1] += postParts.shift(); p.push.apply(p, postParts); } parts.push.apply(parts, p); return parts; } function expandTop(str) { if (!str) return []; // I don't know why Bash 4.3 does this, but it does. // Anything starting with {} will have the first two bytes preserved // but *only* at the top level, so {},a}b will not expand to anything, // but a{},b}c will be expanded to [a}c,abc]. // One could argue that this is a bug in Bash, but since the goal of // this module is to match Bash's rules, we escape a leading {} if (str.substr(0, 2) === '{}') { str = '\\{\\}' + str.substr(2); } return expand(escapeBraces(str), true).map(unescapeBraces); } function identity(e) { return e; } function embrace(str) { return '{' + str + '}'; } function isPadded(el) { return /^-?0\d/.test(el); } function lte(i, y) { return i <= y; } function gte(i, y) { return i >= y; } function expand(str, isTop) { var expansions = []; var m = balanced('{', '}', str); if (!m || /\$$/.test(m.pre)) return [str]; var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); var isSequence = isNumericSequence || isAlphaSequence; var isOptions = m.body.indexOf(',') >= 0; if (!isSequence && !isOptions) { // {a},b} if (m.post.match(/,.*\}/)) { str = m.pre + '{' + m.body + escClose + m.post; return expand(str); } return [str]; } var n; if (isSequence) { n = m.body.split(/\.\./); } else { n = parseCommaParts(m.body); if (n.length === 1) { // x{{a,b}}y ==> x{a}y x{b}y n = expand(n[0], false).map(embrace); if (n.length === 1) { var post = m.post.length ? expand(m.post, false) : ['']; return post.map(function(p) { return m.pre + n[0] + p; }); } } } // at this point, n is the parts, and we know it's not a comma set // with a single entry. // no need to expand pre, since it is guaranteed to be free of brace-sets var pre = m.pre; var post = m.post.length ? expand(m.post, false) : ['']; var N; if (isSequence) { var x = numeric(n[0]); var y = numeric(n[1]); var width = Math.max(n[0].length, n[1].length) var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1; var test = lte; var reverse = y < x; if (reverse) { incr *= -1; test = gte; } var pad = n.some(isPadded); N = []; for (var i = x; test(i, y); i += incr) { var c; if (isAlphaSequence) { c = String.fromCharCode(i); if (c === '\\') c = ''; } else { c = String(i); if (pad) { var need = width - c.length; if (need > 0) { var z = new Array(need + 1).join('0'); if (i < 0) c = '-' + z + c.slice(1); else c = z + c; } } } N.push(c); } } else { N = concatMap(n, function(el) { return expand(el, false) }); } for (var j = 0; j < N.length; j++) { for (var k = 0; k < post.length; k++) { var expansion = pre + N[j] + post[k]; if (!isTop || isSequence || expansion) expansions.push(expansion); } } return expansions; } brace-expansion-1.1.8/package.json000066400000000000000000000021301311744020400170550ustar00rootroot00000000000000{ "name": "brace-expansion", "description": "Brace expansion as known from sh/bash", "version": "1.1.8", "repository": { "type": "git", "url": "git://github.com/juliangruber/brace-expansion.git" }, "homepage": "https://github.com/juliangruber/brace-expansion", "main": "index.js", "scripts": { "test": "tape test/*.js", "gentest": "bash test/generate.sh", "bench": "matcha test/perf/bench.js" }, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" }, "devDependencies": { "matcha": "^0.7.0", "tape": "^4.6.0" }, "keywords": [], "author": { "name": "Julian Gruber", "email": "mail@juliangruber.com", "url": "http://juliangruber.com" }, "license": "MIT", "testling": { "files": "test/*.js", "browsers": [ "ie/8..latest", "firefox/20..latest", "firefox/nightly", "chrome/25..latest", "chrome/canary", "opera/12..latest", "opera/next", "safari/5.1..latest", "ipad/6.0..latest", "iphone/6.0..latest", "android-browser/4.2..latest" ] } } brace-expansion-1.1.8/test/000077500000000000000000000000001311744020400155525ustar00rootroot00000000000000brace-expansion-1.1.8/test/bash-comparison.js000066400000000000000000000016151311744020400212000ustar00rootroot00000000000000var test = require('tape'); var expand = require('..'); var fs = require('fs'); var resfile = __dirname + '/bash-results.txt'; var cases = fs.readFileSync(resfile, 'utf8').split('><><><><'); // throw away the EOF marker cases.pop() test('matches bash expansions', function(t) { cases.forEach(function(testcase) { var set = testcase.split('\n'); var pattern = set.shift(); var actual = expand(pattern); // If it expands to the empty string, then it's actually // just nothing, but Bash is a singly typed language, so // "nothing" is the same as "". if (set.length === 1 && set[0] === '') { set = [] } else { // otherwise, strip off the [] that were added so that // "" expansions would be preserved properly. set = set.map(function (s) { return s.replace(/^\[|\]$/g, '') }) } t.same(actual, set, pattern); }); t.end(); }) brace-expansion-1.1.8/test/bash-results.txt000066400000000000000000000206111311744020400207270ustar00rootroot00000000000000A{b,{d,e},{f,g}}Z [AbZ] [AdZ] [AeZ] [AfZ] [AgZ]><><><><><><><\{a,b}{{a,b},a,b} [{a,b}a] [{a,b}b] [{a,b}a] [{a,b}b]><><><><{{a,b} [{a] [{b]><><><><{a,b}} [a}] [b}]><><><><{,} ><><><><><><><{,}b [b] [b]><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><{-01..5} [-01] [000] [001] [002] [003] [004] [005]><><><><{-05..100..5} [-05] [000] [005] [010] [015] [020] [025] [030] [035] [040] [045] [050] [055] [060] [065] [070] [075] [080] [085] [090] [095] [100]><><><><{-05..100} [-05] [-04] [-03] [-02] [-01] [000] [001] [002] [003] [004] [005] [006] [007] [008] [009] [010] [011] [012] [013] [014] [015] [016] [017] [018] [019] [020] [021] [022] [023] [024] [025] [026] [027] [028] [029] [030] [031] [032] [033] [034] [035] [036] [037] [038] [039] [040] [041] [042] [043] [044] [045] [046] [047] [048] [049] [050] [051] [052] [053] [054] [055] [056] [057] [058] [059] [060] [061] [062] [063] [064] [065] [066] [067] [068] [069] [070] [071] [072] [073] [074] [075] [076] [077] [078] [079] [080] [081] [082] [083] [084] [085] [086] [087] [088] [089] [090] [091] [092] [093] [094] [095] [096] [097] [098] [099] [100]><><><><{0..5..2} [0] [2] [4]><><><><{0001..05..2} [0001] [0003] [0005]><><><><{0001..-5..2} [0001] [-001] [-003] [-005]><><><><{0001..-5..-2} [0001] [-001] [-003] [-005]><><><><{0001..5..-2} [0001] [0003] [0005]><><><><{01..5} [01] [02] [03] [04] [05]><><><><{1..05} [01] [02] [03] [04] [05]><><><><{1..05..3} [01] [04]><><><><{05..100} [005] [006] [007] [008] [009] [010] [011] [012] [013] [014] [015] [016] [017] [018] [019] [020] [021] [022] [023] [024] [025] [026] [027] [028] [029] [030] [031] [032] [033] [034] [035] [036] [037] [038] [039] [040] [041] [042] [043] [044] [045] [046] [047] [048] [049] [050] [051] [052] [053] [054] [055] [056] [057] [058] [059] [060] [061] [062] [063] [064] [065] [066] [067] [068] [069] [070] [071] [072] [073] [074] [075] [076] [077] [078] [079] [080] [081] [082] [083] [084] [085] [086] [087] [088] [089] [090] [091] [092] [093] [094] [095] [096] [097] [098] [099] [100]><><><><{0a..0z} [{0a..0z}]><><><><{a,b\}c,d} [a] [b}c] [d]><><><><{a,b{c,d} [{a,bc] [{a,bd]><><><><{a,b}c,d} [ac,d}] [bc,d}]><><><><{a..F} [a] [`] [_] [^] []] [] [[] [Z] [Y] [X] [W] [V] [U] [T] [S] [R] [Q] [P] [O] [N] [M] [L] [K] [J] [I] [H] [G] [F]><><><><{A..f} [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] [[] [] []] [^] [_] [`] [a] [b] [c] [d] [e] [f]><><><><{a..Z} [a] [`] [_] [^] []] [] [[] [Z]><><><><{A..z} [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] [[] [] []] [^] [_] [`] [a] [b] [c] [d] [e] [f] [g] [h] [i] [j] [k] [l] [m] [n] [o] [p] [q] [r] [s] [t] [u] [v] [w] [x] [y] [z]><><><><{z..A} [z] [y] [x] [w] [v] [u] [t] [s] [r] [q] [p] [o] [n] [m] [l] [k] [j] [i] [h] [g] [f] [e] [d] [c] [b] [a] [`] [_] [^] []] [] [[] [Z] [Y] [X] [W] [V] [U] [T] [S] [R] [Q] [P] [O] [N] [M] [L] [K] [J] [I] [H] [G] [F] [E] [D] [C] [B] [A]><><><><{Z..a} [Z] [[] [] []] [^] [_] [`] [a]><><><><{a..F..2} [a] [_] []] [[] [Y] [W] [U] [S] [Q] [O] [M] [K] [I] [G]><><><><{A..f..02} [A] [C] [E] [G] [I] [K] [M] [O] [Q] [S] [U] [W] [Y] [[] []] [_] [a] [c] [e]><><><><{a..Z..5} [a] []><><><><><><><{A..z..10} [A] [K] [U] [_] [i] [s]><><><><{z..A..-2} [z] [x] [v] [t] [r] [p] [n] [l] [j] [h] [f] [d] [b] [`] [^] [] [Z] [X] [V] [T] [R] [P] [N] [L] [J] [H] [F] [D] [B]><><><><{Z..a..20} [Z]><><><><{a{,b} [{a] [{ab]><><><><{a},b} [a}] [b]><><><><{x,y{,}g} [x] [yg] [yg]><><><><{x,y{}g} [x] [y{}g]><><><><{{a,b} [{a] [{b]><><><><{{a,b},c} [a] [b] [c]><><><><{{a,b}c} [{ac}] [{bc}]><><><><{{a,b},} [a] [b]><><><><><><><{{a,b},}c [ac] [bc] [c]><><><><{{a,b}.} [{a.}] [{b.}]><><><><{{a,b}} [{a}] [{b}]><><><><><><>< ><><><><{-10..00} [-10] [-09] [-08] [-07] [-06] [-05] [-04] [-03] [-02] [-01] [000]><><><><{a,\\{a,b}c} [a] [\ac] [\bc]><><><><{a,\{a,b}c} [ac}] [{ac}] [bc}]><><><><><><><{-10.\.00} [{-10..00}]><><><><><><><><><><{l,n,m}xyz [lxyz] [nxyz] [mxyz]><><><><{abc\,def} [{abc,def}]><><><><{abc} [{abc}]><><><><{x\,y,\{abc\},trie} [x,y] [{abc}] [trie]><><><><{} [{}]><><><><} [}]><><><><{ [{]><><><><><><><{1..10} [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]><><><><{0..10,braces} [0..10] [braces]><><><><{{0..10},braces} [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [braces]><><><><><><><{3..3} [3]><><><><><><><{10..1} [10] [9] [8] [7] [6] [5] [4] [3] [2] [1]><><><><{10..1}y [10y] [9y] [8y] [7y] [6y] [5y] [4y] [3y] [2y] [1y]><><><><><><><{a..f} [a] [b] [c] [d] [e] [f]><><><><{f..a} [f] [e] [d] [c] [b] [a]><><><><{a..A} [a] [`] [_] [^] []] [] [[] [Z] [Y] [X] [W] [V] [U] [T] [S] [R] [Q] [P] [O] [N] [M] [L] [K] [J] [I] [H] [G] [F] [E] [D] [C] [B] [A]><><><><{A..a} [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] [[] [] []] [^] [_] [`] [a]><><><><{f..f} [f]><><><><{1..f} [{1..f}]><><><><{f..1} [{f..1}]><><><><{-1..-10} [-1] [-2] [-3] [-4] [-5] [-6] [-7] [-8] [-9] [-10]><><><><{-20..0} [-20] [-19] [-18] [-17] [-16] [-15] [-14] [-13] [-12] [-11] [-10] [-9] [-8] [-7] [-6] [-5] [-4] [-3] [-2] [-1] [0]><><><><><><><><><><{klklkl}{1,2,3} [{klklkl}1] [{klklkl}2] [{klklkl}3]><><><><{1..10..2} [1] [3] [5] [7] [9]><><><><{-1..-10..2} [-1] [-3] [-5] [-7] [-9]><><><><{-1..-10..-2} [-1] [-3] [-5] [-7] [-9]><><><><{10..1..-2} [10] [8] [6] [4] [2]><><><><{10..1..2} [10] [8] [6] [4] [2]><><><><{1..20..2} [1] [3] [5] [7] [9] [11] [13] [15] [17] [19]><><><><{1..20..20} [1]><><><><{100..0..5} [100] [95] [90] [85] [80] [75] [70] [65] [60] [55] [50] [45] [40] [35] [30] [25] [20] [15] [10] [5] [0]><><><><{100..0..-5} [100] [95] [90] [85] [80] [75] [70] [65] [60] [55] [50] [45] [40] [35] [30] [25] [20] [15] [10] [5] [0]><><><><{a..z} [a] [b] [c] [d] [e] [f] [g] [h] [i] [j] [k] [l] [m] [n] [o] [p] [q] [r] [s] [t] [u] [v] [w] [x] [y] [z]><><><><{a..z..2} [a] [c] [e] [g] [i] [k] [m] [o] [q] [s] [u] [w] [y]><><><><{z..a..-2} [z] [x] [v] [t] [r] [p] [n] [l] [j] [h] [f] [d] [b]><><><><{2147483645..2147483649} [2147483645] [2147483646] [2147483647] [2147483648] [2147483649]><><><><{10..0..2} [10] [8] [6] [4] [2] [0]><><><><{10..0..-2} [10] [8] [6] [4] [2] [0]><><><><{-50..-0..5} [-50] [-45] [-40] [-35] [-30] [-25] [-20] [-15] [-10] [-5] [0]><><><><{1..10.f} [{1..10.f}]><><><><{1..ff} [{1..ff}]><><><><{1..10..ff} [{1..10..ff}]><><><><{1.20..2} [{1.20..2}]><><><><{1..20..f2} [{1..20..f2}]><><><><{1..20..2f} [{1..20..2f}]><><><><{1..2f..2} [{1..2f..2}]><><><><{1..ff..2} [{1..ff..2}]><><><><{1..ff} [{1..ff}]><><><><{1..f} [{1..f}]><><><><{1..0f} [{1..0f}]><><><><{1..10f} [{1..10f}]><><><><{1..10.f} [{1..10.f}]><><><><{},b}.h [{},b}.h]><><><><><><><{}{},a}b [{}}b] [{}ab]><><><><{{},a}}b [{}}b] [a}b]><><><><{}{{},a}}b [{}{}}b] [{}a}b]><><><><{}a,b}c [{}a,b}c]><><><><brace-expansion-1.1.8/test/cases.txt000066400000000000000000000054351311744020400174200ustar00rootroot00000000000000# skip quotes for now # "{x,x}" # {"x,x"} # {x","x} # '{a,b}{{a,b},a,b}' A{b,{d,e},{f,g}}Z PRE-{a,b}{{a,b},a,b}-POST \\{a,b}{{a,b},a,b} {{a,b} {a,b}} {,} a{,} {,}b a{,}b a{b}c a{1..5}b a{01..5}b a{-01..5}b a{-01..5..3}b a{001..9}b a{b,c{d,e},{f,g}h}x{y,z a{b,c{d,e},{f,g}h}x{y,z\\} a{b,c{d,e},{f,g}h}x{y,z} a{b{c{d,e}f{x,y{{g}h a{b{c{d,e}f{x,y{}g}h a{b{c{d,e}f{x,y}}g}h a{b{c{d,e}f}g}h a{{x,y},z}b f{x,y{g,z}}h f{x,y{{g,z}}h f{x,y{{g,z}}h} f{x,y{{g}h f{x,y{{g}}h f{x,y{}g}h z{a,b{,c}d z{a,b},c}d {-01..5} {-05..100..5} {-05..100} {0..5..2} {0001..05..2} {0001..-5..2} {0001..-5..-2} {0001..5..-2} {01..5} {1..05} {1..05..3} {05..100} {0a..0z} {a,b\\}c,d} {a,b{c,d} {a,b}c,d} {a..F} {A..f} {a..Z} {A..z} {z..A} {Z..a} {a..F..2} {A..f..02} {a..Z..5} d{a..Z..5}b {A..z..10} {z..A..-2} {Z..a..20} {a{,b} {a},b} {x,y{,}g} {x,y{}g} {{a,b} {{a,b},c} {{a,b}c} {{a,b},} X{{a,b},}X {{a,b},}c {{a,b}.} {{a,b}} X{a..#}X # this next one is an empty string {-10..00} # Need to escape slashes in here for reasons i guess. {a,\\\\{a,b}c} {a,\\{a,b}c} a,\\{b,c} {-10.\\.00} #### bash tests/braces.tests # Note that some tests are edited out because some features of # bash are intentionally not supported in this brace expander. ff{c,b,a} f{d,e,f}g {l,n,m}xyz {abc\\,def} {abc} {x\\,y,\\{abc\\},trie} # not impementing back-ticks obviously # XXXX\\{`echo a b c | tr ' ' ','`\\} {} # We only ever have to worry about parsing a single argument, # not a command line, so spaces have a different meaning than bash. # { } } { abcd{efgh # spaces # foo {1,2} bar # not impementing back-ticks obviously # `zecho foo {1,2} bar` # $(zecho foo {1,2} bar) # ${var} is not a variable here, like it is in bash. omit. # foo{bar,${var}.} # foo{bar,${var}} # isaacs: skip quotes for now # "${var}"{x,y} # $var{x,y} # ${var}{x,y} # new sequence brace operators {1..10} # this doesn't work yet {0..10,braces} # but this does {{0..10},braces} x{{0..10},braces}y {3..3} x{3..3}y {10..1} {10..1}y x{10..1}y {a..f} {f..a} {a..A} {A..a} {f..f} # mixes are incorrectly-formed brace expansions {1..f} {f..1} # spaces # 0{1..9} {10..20} # do negative numbers work? {-1..-10} {-20..0} # weirdly-formed brace expansions -- fixed in post-bash-3.1 a-{b{d,e}}-c a-{bdef-{g,i}-c # isaacs: skip quotes for now # {"klklkl"}{1,2,3} # isaacs: this is a valid test, though {klklkl}{1,2,3} # {"x,x"} {1..10..2} {-1..-10..2} {-1..-10..-2} {10..1..-2} {10..1..2} {1..20..2} {1..20..20} {100..0..5} {100..0..-5} {a..z} {a..z..2} {z..a..-2} # make sure brace expansion handles ints > 2**31 - 1 using intmax_t {2147483645..2147483649} # unwanted zero-padding -- fixed post-bash-4.0 {10..0..2} {10..0..-2} {-50..-0..5} # bad {1..10.f} {1..ff} {1..10..ff} {1.20..2} {1..20..f2} {1..20..2f} {1..2f..2} {1..ff..2} {1..ff} {1..f} {1..0f} {1..10f} {1..10.f} {},b}.h y{},a}x {}{},a}b {{},a}}b {}{{},a}}b {}a,b}c brace-expansion-1.1.8/test/dollar.js000066400000000000000000000004201311744020400173610ustar00rootroot00000000000000var test = require('tape'); var expand = require('..'); test('ignores ${', function(t) { t.deepEqual(expand('${1..3}'), ['${1..3}']); t.deepEqual(expand('${a,b}${c,d}'), ['${a,b}${c,d}']); t.deepEqual(expand('x${a,b}x${c,d}x'), ['x${a,b}x${c,d}x']); t.end(); }); brace-expansion-1.1.8/test/empty-option.js000066400000000000000000000002671311744020400205610ustar00rootroot00000000000000var test = require('tape'); var expand = require('..'); test('empty option', function(t) { t.deepEqual(expand('-v{,,,,}'), [ '-v', '-v', '-v', '-v', '-v' ]); t.end(); }); brace-expansion-1.1.8/test/generate.sh000077500000000000000000000010321311744020400176770ustar00rootroot00000000000000#!/usr/bin/env bash set -e # Bash 4.3 because of arbitrary need to pick a single standard. if [ "${BASH_VERSINFO[0]}" != "4" ] || [ "${BASH_VERSINFO[1]}" != "3" ]; then echo "this script requires bash 4.3" >&2 exit 1 fi CDPATH= cd "$(dirname "$0")" js='require("./")(process.argv[1]).join(" ")' cat cases.txt | \ while read case; do if [ "${case:0:1}" = "#" ]; then continue; fi; b="$($BASH -c 'for c in '"$case"'; do echo ["$c"]; done')" echo "$case" echo -n "$b><><><><"; done > bash-results.txt brace-expansion-1.1.8/test/negative-increment.js000066400000000000000000000007421311744020400216770ustar00rootroot00000000000000var test = require('tape'); var expand = require('..'); test('negative increment', function(t) { t.deepEqual(expand('{3..1}'), ['3', '2', '1']); t.deepEqual(expand('{10..8}'), ['10', '9', '8']); t.deepEqual(expand('{10..08}'), ['10', '09', '08']); t.deepEqual(expand('{c..a}'), ['c', 'b', 'a']); t.deepEqual(expand('{4..0..2}'), ['4', '2', '0']); t.deepEqual(expand('{4..0..-2}'), ['4', '2', '0']); t.deepEqual(expand('{e..a..2}'), ['e', 'c', 'a']); t.end(); }); brace-expansion-1.1.8/test/nested.js000066400000000000000000000006141311744020400173730ustar00rootroot00000000000000var test = require('tape'); var expand = require('..'); test('nested', function(t) { t.deepEqual(expand('{a,b{1..3},c}'), [ 'a', 'b1', 'b2', 'b3', 'c' ]); t.deepEqual(expand('{{A..Z},{a..z}}'), 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('') ); t.deepEqual(expand('ppp{,config,oe{,conf}}'), [ 'ppp', 'pppconfig', 'pppoe', 'pppoeconf' ]); t.end(); }); brace-expansion-1.1.8/test/order.js000066400000000000000000000002501311744020400172200ustar00rootroot00000000000000var test = require('tape'); var expand = require('..'); test('order', function(t) { t.deepEqual(expand('a{d,c,b}e'), [ 'ade', 'ace', 'abe' ]); t.end(); }); brace-expansion-1.1.8/test/pad.js000066400000000000000000000003371311744020400166570ustar00rootroot00000000000000var test = require('tape'); var expand = require('..'); test('pad', function(t) { t.deepEqual(expand('{9..11}'), [ '9', '10', '11' ]); t.deepEqual(expand('{09..11}'), [ '09', '10', '11' ]); t.end(); }); brace-expansion-1.1.8/test/perf/000077500000000000000000000000001311744020400165065ustar00rootroot00000000000000brace-expansion-1.1.8/test/perf/bench.js000066400000000000000000000004171311744020400201250ustar00rootroot00000000000000'use strict'; var expand = require('../../'); var fs = require('fs'); var resfile = __dirname + '/../cases.txt'; var cases = fs.readFileSync(resfile, 'utf8').split('\n'); bench('Average', function() { cases.forEach(function(testcase) { expand(testcase); }); }); brace-expansion-1.1.8/test/same-type.js000066400000000000000000000002401311744020400200100ustar00rootroot00000000000000var test = require('tape'); var expand = require('..'); test('x and y of same type', function(t) { t.deepEqual(expand('{a..9}'), ['{a..9}']); t.end(); }); brace-expansion-1.1.8/test/sequence.js000066400000000000000000000020641311744020400177220ustar00rootroot00000000000000var test = require('tape'); var expand = require('..'); test('numeric sequences', function(t) { t.deepEqual(expand('a{1..2}b{2..3}c'), [ 'a1b2c', 'a1b3c', 'a2b2c', 'a2b3c' ]); t.deepEqual(expand('{1..2}{2..3}'), [ '12', '13', '22', '23' ]); t.end(); }); test('numeric sequences with step count', function(t) { t.deepEqual(expand('{0..8..2}'), [ '0', '2', '4', '6', '8' ]); t.deepEqual(expand('{1..8..2}'), [ '1', '3', '5', '7' ]); t.end(); }); test('numeric sequence with negative x / y', function(t) { t.deepEqual(expand('{3..-2}'), [ '3', '2', '1', '0', '-1', '-2' ]); t.end(); }); test('alphabetic sequences', function(t) { t.deepEqual(expand('1{a..b}2{b..c}3'), [ '1a2b3', '1a2c3', '1b2b3', '1b2c3' ]); t.deepEqual(expand('{a..b}{b..c}'), [ 'ab', 'ac', 'bb', 'bc' ]); t.end(); }); test('alphabetic sequences with step count', function(t) { t.deepEqual(expand('{a..k..2}'), [ 'a', 'c', 'e', 'g', 'i', 'k' ]); t.deepEqual(expand('{b..k..2}'), [ 'b', 'd', 'f', 'h', 'j' ]); t.end(); });