62bc7bae3fed28b9082a4884b4bfbe484a2f38ec
[platform/framework/web/crosswalk-tizen.git] /
1 # brace-expansion
2
3 [Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html), 
4 as known from sh/bash, in JavaScript.
5
6 [![build status](https://secure.travis-ci.org/juliangruber/brace-expansion.svg)](http://travis-ci.org/juliangruber/brace-expansion)
7
8 [![testling badge](https://ci.testling.com/juliangruber/brace-expansion.png)](https://ci.testling.com/juliangruber/brace-expansion)
9
10 ## Example
11
12 ```js
13 var expand = require('brace-expansion');
14
15 expand('file-{a,b,c}.jpg')
16 // => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
17
18 expand('-v{,,}')
19 // => ['-v', '-v', '-v']
20
21 expand('file{0..2}.jpg')
22 // => ['file0.jpg', 'file1.jpg', 'file2.jpg']
23
24 expand('file-{a..c}.jpg')
25 // => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
26
27 expand('file{2..0}.jpg')
28 // => ['file2.jpg', 'file1.jpg', 'file0.jpg']
29
30 expand('file{0..4..2}.jpg')
31 // => ['file0.jpg', 'file2.jpg', 'file4.jpg']
32
33 expand('file-{a..e..2}.jpg')
34 // => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg']
35
36 expand('file{00..10..5}.jpg')
37 // => ['file00.jpg', 'file05.jpg', 'file10.jpg']
38
39 expand('{{A..C},{a..c}}')
40 // => ['A', 'B', 'C', 'a', 'b', 'c']
41
42 expand('ppp{,config,oe{,conf}}')
43 // => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf']
44 ```
45
46 ## API
47
48 ```js
49 var expand = require('brace-expansion');
50 ```
51
52 ### var expanded = expand(str)
53
54 Return an array of all possible and valid expansions of `str`. If none are
55 found, `[str]` is returned.
56
57 Valid expansions are:
58
59 ```js
60 /^(.*,)+(.+)?$/
61 // {a,b,...}
62 ```
63
64 A comma seperated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`.
65
66 ```js
67 /^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
68 // {x..y[..incr]}
69 ```
70
71 A numeric sequence from `x` to `y` inclusive, with optional increment.
72 If `x` or `y` start with a leading `0`, all the numbers will be padded
73 to have equal length. Negative numbers and backwards iteration work too.
74
75 ```js
76 /^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
77 // {x..y[..incr]}
78 ```
79
80 An alphabetic sequence from `x` to `y` inclusive, with optional increment.
81 `x` and `y` must be exactly one character, and if given, `incr` must be a
82 number.
83
84 For compatibility reasons, the string `${` is not eligible for brace expansion.
85
86 ## Installation
87
88 With [npm](https://npmjs.org) do:
89
90 ```bash
91 npm install brace-expansion
92 ```
93
94 ## Contributors
95
96 - [Julian Gruber](https://github.com/juliangruber)
97 - [Isaac Z. Schlueter](https://github.com/isaacs)
98
99 ## License
100
101 (MIT)
102
103 Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
104
105 Permission is hereby granted, free of charge, to any person obtaining a copy of
106 this software and associated documentation files (the "Software"), to deal in
107 the Software without restriction, including without limitation the rights to
108 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
109 of the Software, and to permit persons to whom the Software is furnished to do
110 so, subject to the following conditions:
111
112 The above copyright notice and this permission notice shall be included in all
113 copies or substantial portions of the Software.
114
115 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
116 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
117 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
118 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
119 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
120 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
121 SOFTWARE.