brace-expansion
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
balanced-match | 1.0.2 | 2.61 kB | MIT | prod |
Brace-expansion is a powerful JavaScript tool that parallels the functionality of brace expansion in shell/bash. Its primary function is to generate an array of all valid and possible expansions of a given string. If no expansions are found, it returns an array containing the original string. The brace-expansion tool supports a range of valid expansions including comma-separated lists of options, numeric sequences, and alphabetic sequences. It is designed for compatibility and does not allow the string "${" for brace expansion.
To make use of the brace-expansion tool in your JavaScript code, you need to require it in your program as follows: var expand = require('brace-expansion');
. To then carry out a brace expansion, you call the expand
function with your string as the argument. For example, to expand a string representing a range of filenames, you may write expand('file-{a,b,c}.jpg')
. This will return an array as follows: ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
.
Here are some more examples:
expand('-v{,,}') // returns ['-v', '-v', '-v']
expand('file{0..2}.jpg') // returns ['file0.jpg', 'file1.jpg', 'file2.jpg']
expand('file-{a..c}.jpg') // returns ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
expand('file{2..0}.jpg') // returns ['file2.jpg', 'file1.jpg', 'file0.jpg']
expand('file{0..4..2}.jpg') // returns ['file0.jpg', 'file2.jpg', 'file4.jpg']
expand('file-{a..e..2}.jpg') // returns ['file-a.jpg', 'file-c.jpg', 'file-e.jpg']
expand('file{00..10..5}.jpg') //returns ['file00.jpg', 'file05.jpg', 'file10.jpg']
expand('{{A..C},{a..c}}') // returns ['A', 'B', 'C', 'a', 'b', 'c']
expand('ppp{,config,oe{,conf}}') // returns ['ppp', 'pppconfig', 'pppoe', 'pppoeconf']
For more information on using brace-expansion, including its API and installation instructions, refer to the documentation on the GitHub repository at git://github.com/juliangruber/brace-expansion.git. The 'README' file contained within the repository provides a comprehensive overview of brace-expansion's functionalities, usage examples, and more.