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)
3 Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See the benchmarks. Used by micromatch.
7 Install with [npm](https://www.npmjs.com/):
10 $ npm install expand-range --save
13 Wraps [fill-range] to do range expansion using `..` separated strings. See [fill-range] for the full list of options and features.
18 var expand = require('expand-range');
24 expand(start, stop, increment);
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
35 //=> ['a', 'b', 'c', 'd', 'e']
47 //=> [ '0', '-1', '-2', '-3', '-4', '-5' ]
50 //=> [ '-9', '-6', '-3', '0', '3', '6', '9' ])
53 //=> [ '-1', '-3', '-5', '-7', '-9' ]
56 //=> [ '1', '3', '5', '7', '9' ]
61 Optionally pass a custom function as the second argument:
64 expand('a..e', function (val, isNumber, pad, i) {
66 return String.fromCharCode(val) + i;
70 //=> ['a0', 'b1', 'c2', 'd3', 'e4']
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)
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)
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)
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)
99 You might also be interested in these projects:
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)
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).
111 Generate readme and API documentation with [verb](https://github.com/verbose/verb):
114 $ npm install verb && npm run docs
117 Or, if [verb](https://github.com/verbose/verb) is installed globally:
125 Install dev dependencies:
128 $ npm install -d && npm test
135 * [github/jonschlinkert](https://github.com/jonschlinkert)
136 * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
140 Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
141 Released under the [MIT license](https://github.com/jonschlinkert/expand-range/blob/master/LICENSE).
145 _This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on May 05, 2016._