# expand-range

> Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. Used by micromatch.

Latest version **2.0.2** (published 2018-11-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install expand-range
pnpm add expand-range
yarn add expand-range
bun add expand-range
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2018-11-26 |
| First published | 2014-10-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 2 |
| Unpacked size | 9.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 25 |
| Author | Jon Schlinkert |
| Maintainers | doowb, jonschlinkert |
| Keywords | alpha, alphabetical, bash, brace, expand, expansion, glob, match, matches, matching, number, numerical, range, ranges, sh |

## Links

- npm: https://www.npmjs.com/package/expand-range
- Repository: https://github.com/jonschlinkert/expand-range
- Issues: https://github.com/jonschlinkert/expand-range/issues
- npm.io page: https://npm.io/package/expand-range

## Dependencies (2)

- [fill-range](https://npm.io/package/fill-range.md) ^5.0.0
- [extend-shallow](https://npm.io/package/extend-shallow.md) ^2.0.1

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 2.0.2 (latest) — 2018-11-26
- 2.0.1 — 2017-05-09
- 2.0.0 — 2017-05-09
- 1.8.2 — 2016-05-05
- 1.8.1 — 2015-02-15
- 1.8.0 — 2015-01-30
- 1.7.0 — 2015-01-30
- 1.6.0 — 2015-01-25
- 1.5.0 — 2015-01-24
- 1.4.0 — 2015-01-24
- 1.2.0 — 2015-01-14
- 1.1.0 — 2015-01-12
- 1.0.0 — 2015-01-04
- 0.3.1 — 2014-12-14
- 0.3.0 — 2014-12-14
- … 4 more at https://npm.io/package/expand-range/versions

## README

# expand-range [![NPM version](https://img.shields.io/npm/v/expand-range.svg?style=flat)](https://www.npmjs.com/package/expand-range) [![NPM monthly downloads](https://img.shields.io/npm/dm/expand-range.svg?style=flat)](https://npmjs.org/package/expand-range) [![NPM total downloads](https://img.shields.io/npm/dt/expand-range.svg?style=flat)](https://npmjs.org/package/expand-range) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/expand-range.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/expand-range)

> Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. Used by micromatch.

Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install --save expand-range
```

## Example usage

```js
var expand = require('expand-range');
expand('start..end..step', options);

// examples
console.log(expand('1..3')) //=> ['1', '2', '3']
console.log(expand('1..10..3')) //=> [ '1', '4', '7', '10' ]
```

**Params**

* `start`: the number or letter to start with
* `end`: the number or letter to end with
* `step`: (optional) the step/increment to use. works with letters and numbers.
* `options`: Options object to pass to [fill-range](https://github.com/jonschlinkert/fill-range), or a transform function (see [fill-range](https://github.com/jonschlinkert/fill-range) readme for details and documentation)

This library wraps [fill-range](https://github.com/jonschlinkert/fill-range) to support range expansion using `..` separated strings. See [fill-range](https://github.com/jonschlinkert/fill-range) for the full list of options and features.

**Examples**

```js
expand('a..e')
//=> ['a', 'b', 'c', 'd', 'e']

expand('a..e..2')
//=> ['a', 'c', 'e']

expand('A..E..2')
//=> ['A', 'C', 'E']

expand('1..3')
//=> ['1', '2', '3']

expand('0..-5')
//=> [ '0', '-1', '-2', '-3', '-4', '-5' ]

expand('-9..9..3')
//=> [ '-9', '-6', '-3', '0', '3', '6', '9' ])

expand('-1..-10..-2')
//=> [ '-1', '-3', '-5', '-7', '-9' ]

expand('1..10..2')
//=> [ '1', '3', '5', '7', '9' ]
```

### Custom function

Optionally pass a custom function as the second argument:

```js
expand('a..e', function (val, isNumber, pad, i) {
  if (!isNumber) {
    return String.fromCharCode(val) + i;
  }
  return val;
});
//=> ['a0', 'b1', 'c2', 'd3', 'e4']
```

## Benchmarks

```sh
[object Object]
```

## History

### v2.0.0

**Changes**

* Special `step` characters are no longer supported, as the same thing can be accomplished with a custom transform function.
* The signature in the [transform function](https://github.com/jonschlinkert/fill-range#optionstransform) has changed. See [fill-range](https://github.com/jonschlinkert/fill-range) for more details.

## About

<details>
<summary><strong>Contributing</strong></summary>

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).

</details>

<details>
<summary><strong>Running Tests</strong></summary>

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

```sh
$ npm install && npm test
```

</details>

<details>
<summary><strong>Building docs</strong></summary>

_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_

To generate the readme, run the following command:

```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```

</details>

### Related projects

You might also be interested in these projects:

* [braces](https://www.npmjs.com/package/braces): Bash-like brace expansion, implemented in JavaScript. Safer than other brace expansion libs, with complete support… [more](https://github.com/micromatch/braces) | [homepage](https://github.com/micromatch/braces "Bash-like brace expansion, implemented in JavaScript. Safer than other brace expansion libs, with complete support for the Bash 4.3 braces specification, without sacrificing speed.")
* [fill-range](https://www.npmjs.com/package/fill-range): Fill in a range of numbers or letters, optionally passing an increment or `step` to… [more](https://github.com/jonschlinkert/fill-range) | [homepage](https://github.com/jonschlinkert/fill-range "Fill in a range of numbers or letters, optionally passing an increment or `step` to use, or create a regex-compatible range with `options.toRegex`")
* [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/micromatch/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.")

### Contributors

| **Commits** | **Contributor** |  
| --- | --- |  
| 65 | [jonschlinkert](https://github.com/jonschlinkert) |  
| 1  | [dcohenb](https://github.com/dcohenb) |  
| 1  | [stevelacy](https://github.com/stevelacy) |  

### Author

**Jon Schlinkert**

* [GitHub Profile](https://github.com/jonschlinkert)
* [Twitter Profile](https://twitter.com/jonschlinkert)
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)

### License

Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).

***

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on November 26, 2018._

---
_Source: https://npm.io/package/expand-range · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
