| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/gavin/workspace/readjs/node_modules/expand-braces/node_modules/expand-range/ |
Upload File : |
# {%= name %} {%= badge("fury") %}
> {%= description %}
## Benchmarks
```bash
node benchmark
```
## Example usage
```js
var expand = require('{%= name %}');
expand('1..3')
//=> ['1', '2', '3']
expand('5..8')
//=> ['5', '6', '7', '8']
expand('00..05')
//=> ['00', '01', '02', '03', '04', '05']
expand('01..03')
//=> ['01', '02', '03']
expand('000..005')
//=> ['000', '001', '002', '003', '004', '005']
expand('a..e')
//=> ['a', 'b', 'c', 'd', 'e']
expand('A..E')
//=> ['A', 'B', 'C', 'D', 'E']
```
### Custom function
Pass a function as the last argument to customize the expansions:
**Params:**
- `str` the expanded string
- `ch` the [unicode value][unicode] for the string
- `i` the current index
**Example using the `str` value:**
```js
var range = expand('a..e', function (str, ch, i) {
return str + i;
});
console.log(range);
//=> ['a0', 'b1', 'c2', 'd3', 'e4']
```
**Example using the unicode value:**
```js
var range = expand('a..e', function (str, ch, i) {
return String.fromCharCode(ch) + i;
});
console.log(range);
//=> ['a0', 'b1', 'c2', 'd3', 'e4']
```
## Install
{%= include("install") %}
## Run tests
```bash
npm test
```
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue]({%= bugs.url %}).
## Author
{%= include("author") %}
## License
{%= copyright() %}
{%= license() %}
***
{%= include("footer") %}
[unicode]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode