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