source: node_modules/brace-expansion/README.md

main
Last change on this file was 33517cc, checked in by Klimentina Efremova <klimentina08642@…>, 10 days ago

Turned database from SQLite to PostgressSQL, updated database changes from Phase 1 and 2

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[81bc7da]1# brace-expansion
2
3[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html),
4as known from sh/bash, in JavaScript.
5
6[![CI](https://github.com/juliangruber/brace-expansion/actions/workflows/ci.yml/badge.svg)](https://github.com/juliangruber/brace-expansion/actions/workflows/ci.yml)
7[![downloads](https://img.shields.io/npm/dm/brace-expansion.svg)](https://www.npmjs.org/package/brace-expansion)
8
9## Example
10
11```js
12import { expand } from 'brace-expansion'
13
14expand('file-{a,b,c}.jpg')
15// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
16
17expand('-v{,,}')
18// => ['-v', '-v', '-v']
19
20expand('file{0..2}.jpg')
21// => ['file0.jpg', 'file1.jpg', 'file2.jpg']
22
23expand('file-{a..c}.jpg')
24// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
25
26expand('file{2..0}.jpg')
27// => ['file2.jpg', 'file1.jpg', 'file0.jpg']
28
29expand('file{0..4..2}.jpg')
30// => ['file0.jpg', 'file2.jpg', 'file4.jpg']
31
32expand('file-{a..e..2}.jpg')
33// => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg']
34
35expand('file{00..10..5}.jpg')
36// => ['file00.jpg', 'file05.jpg', 'file10.jpg']
37
38expand('{{A..C},{a..c}}')
39// => ['A', 'B', 'C', 'a', 'b', 'c']
40
41expand('ppp{,config,oe{,conf}}')
42// => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf']
43```
44
45## API
46
47```js
[33517cc]48import { expand } from 'brace-expansion'
[81bc7da]49```
50
51### const expanded = expand(str, [options])
52
53Return an array of all possible and valid expansions of `str`. If
54none are found, `[str]` is returned.
55
56The `options` object can provide a `max` value to cap the number
57of expansions allowed. This is limited to `100_000` by default,
58to prevent DoS attacks.
59
60```js
61const expansions = expand('{1..100}'.repeat(5), {
62 max: 100,
63})
64// expansions.length will be 100, not 100^5
65```
66
[33517cc]67The `options` object can also provide a `maxLength` value to cap the
68total number of characters across all expansions. This is limited to
69`4_000_000` by default, to prevent memory exhaustion from inputs whose
70result count stays under `max` while each result grows very long.
71
72```js
73const expansions = expand('{a,b}'.repeat(1500), {
74 maxLength: 10_000,
75})
76```
77
[81bc7da]78Valid expansions are:
79
80```js
81;/^(.*,)+(.+)?$/
82// {a,b,...}
83```
84
85A comma separated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`.
86
87```js
88;/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
89// {x..y[..incr]}
90```
91
92A numeric sequence from `x` to `y` inclusive, with optional increment.
93If `x` or `y` start with a leading `0`, all the numbers will be padded
94to have equal length. Negative numbers and backwards iteration work too.
95
96```js
97;/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
98// {x..y[..incr]}
99```
100
101An alphabetic sequence from `x` to `y` inclusive, with optional increment.
102`x` and `y` must be exactly one character, and if given, `incr` must be a
103number.
104
105For compatibility reasons, the string `${` is not eligible for brace expansion.
Note: See TracBrowser for help on using the repository browser.