Initial commit
[yaffs-website] / node_modules / expand-range / README.md
1 # expand-range [![NPM version](https://img.shields.io/npm/v/expand-range.svg?style=flat)](https://www.npmjs.com/package/expand-range) [![NPM downloads](https://img.shields.io/npm/dm/expand-range.svg?style=flat)](https://npmjs.org/package/expand-range) [![Build Status](https://img.shields.io/travis/jonschlinkert/expand-range.svg?style=flat)](https://travis-ci.org/jonschlinkert/expand-range)
2
3 Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See the benchmarks. Used by micromatch.
4
5 ## Install
6
7 Install with [npm](https://www.npmjs.com/):
8
9 ```sh
10 $ npm install expand-range --save
11 ```
12
13 Wraps [fill-range] to do range expansion using `..` separated strings. See [fill-range] for the full list of options and features.
14
15 ## Example usage
16
17 ```js
18 var expand = require('expand-range');
19 ```
20
21 **Params**
22
23 ```js
24 expand(start, stop, increment);
25 ```
26
27 * `start`: the number or letter to start with
28 * `end`: the number or letter to end with
29 * `increment`: optionally pass the increment to use. works for letters or numbers
30
31 **Examples**
32
33 ```js
34 expand('a..e')
35 //=> ['a', 'b', 'c', 'd', 'e']
36
37 expand('a..e..2')
38 //=> ['a', 'c', 'e']
39
40 expand('A..E..2')
41 //=> ['A', 'C', 'E']
42
43 expand('1..3')
44 //=> ['1', '2', '3']
45
46 expand('0..-5')
47 //=> [ '0', '-1', '-2', '-3', '-4', '-5' ]
48
49 expand('-9..9..3')
50 //=> [ '-9', '-6', '-3', '0', '3', '6', '9' ])
51
52 expand('-1..-10..-2')
53 //=> [ '-1', '-3', '-5', '-7', '-9' ]
54
55 expand('1..10..2')
56 //=> [ '1', '3', '5', '7', '9' ]
57 ```
58
59 ### Custom function
60
61 Optionally pass a custom function as the second argument:
62
63 ```js
64 expand('a..e', function (val, isNumber, pad, i) {
65   if (!isNumber) {
66     return String.fromCharCode(val) + i;
67   }
68   return val;
69 });
70 //=> ['a0', 'b1', 'c2', 'd3', 'e4']
71 ```
72
73 ## Benchmarks
74
75 ```sh
76 # benchmark/fixtures/alpha-lower.js (29 bytes)
77   brace-expansion x 145,653 ops/sec ±0.89% (87 runs sampled)
78   expand-range x 453,213 ops/sec ±1.66% (85 runs sampled)
79   minimatch x 152,193 ops/sec ±1.17% (86 runs sampled)
80
81 # benchmark/fixtures/alpha-upper.js (29 bytes)
82   brace-expansion x 149,975 ops/sec ±1.10% (88 runs sampled)
83   expand-range x 459,390 ops/sec ±1.27% (84 runs sampled)
84   minimatch x 155,253 ops/sec ±1.25% (88 runs sampled)
85
86 # benchmark/fixtures/padded.js (33 bytes)
87   brace-expansion x 14,694 ops/sec ±1.37% (85 runs sampled)
88   expand-range x 169,393 ops/sec ±1.76% (80 runs sampled)
89   minimatch x 15,052 ops/sec ±1.15% (88 runs sampled)
90
91 # benchmark/fixtures/range.js (29 bytes)
92   brace-expansion x 142,968 ops/sec ±1.35% (86 runs sampled)
93   expand-range x 465,579 ops/sec ±1.43% (86 runs sampled)
94   minimatch x 126,872 ops/sec ±1.18% (90 runs sampled)
95 ```
96
97 ## Related projects
98
99 You might also be interested in these projects:
100
101 * [braces](https://www.npmjs.com/package/braces): Fastest brace expansion for node.js, with the most complete support for the Bash 4.3 braces… [more](https://www.npmjs.com/package/braces) | [homepage](https://github.com/jonschlinkert/braces)
102 * [fill-range](https://www.npmjs.com/package/fill-range): Fill in a range of numbers or letters, optionally passing an increment or multiplier to… [more](https://www.npmjs.com/package/fill-range) | [homepage](https://github.com/jonschlinkert/fill-range)
103 * [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | [homepage](https://github.com/jonschlinkert/micromatch)
104
105 ## Contributing
106
107 Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/expand-range/issues/new).
108
109 ## Building docs
110
111 Generate readme and API documentation with [verb](https://github.com/verbose/verb):
112
113 ```sh
114 $ npm install verb && npm run docs
115 ```
116
117 Or, if [verb](https://github.com/verbose/verb) is installed globally:
118
119 ```sh
120 $ verb
121 ```
122
123 ## Running tests
124
125 Install dev dependencies:
126
127 ```sh
128 $ npm install -d && npm test
129 ```
130
131 ## Author
132
133 **Jon Schlinkert**
134
135 * [github/jonschlinkert](https://github.com/jonschlinkert)
136 * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
137
138 ## License
139
140 Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
141 Released under the [MIT license](https://github.com/jonschlinkert/expand-range/blob/master/LICENSE).
142
143 ***
144
145 _This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on May 05, 2016._