# parse-numeric-range

> Takes a string, such as "1,2,3-10,5-8" and turns it into an array of numbers

Latest version **1.3.0** (published 2021-08-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install parse-numeric-range
pnpm add parse-numeric-range
yarn add parse-numeric-range
bun add parse-numeric-range
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2021-08-22 |
| First published | 2014-06-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/parse-numeric-range) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | Euan Kemp |
| Maintainers | euank |
| Keywords | parse, numbers, ranges, utility, arrays |

## Links

- npm: https://www.npmjs.com/package/parse-numeric-range
- Repository: https://github.com/euank/node-parse-numeric-range
- Issues: https://github.com/euank/node-parse-numeric-range/issues
- npm.io page: https://npm.io/package/parse-numeric-range

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.3.0 (latest) — 2021-08-22
- 1.2.0 — 2020-04-28
- 1.1.0 — 2020-04-10
- 1.0.0 — 2020-04-10
- 0.0.2 — 2014-12-02
- 0.0.1 — 2014-06-19

## README

node-parse-numeric-range
========================

Parses expressions like 1-10,20-30. Returns an energetic (as opposed to lazy) array.


## Supported Expressions
Comprehensive supported expression examples:

| Expression | result       |
|:----------:|:------------:|
|            |   []         |
|     1      |   [1]        |
|    1,2     |  [1,2]       |
|    -10     |  [-10]       |
|   -3,-3    |[-3, -3]      |
|  -1-2,-2   |[-1,0,1,2,-2] |
|  -1--2     |[-1,-2]       |
|  -1..2,-2  |[-1,0,1,2,-2] |
|  -1...3,-2 |[-1,0,1,2,-2] |
|   1⋯3      |[1,2]         |
|  1…3       |[1,2]         |
|  1‥3       |[1,2,3]       |


What's this useful for? Well, letting users input these sorts of things and then
making them programmatically useful.


## Usage

First, `npm install parse-numeric-range`.

```javascript
const rangeParser = require("parse-numeric-range");

const numbers = rangeParser("4,6,8-10,12,14..16,18,20...23");

console.log(
  `The first ${numbers.length} composite numbers are: ${numbers.join(", ")}`,
);
```

### ES6
```jsx
import rangeParser from "parse-numeric-range";

const numbers = rangeParser("4,6,8-10,12,14..16,18,20...23");

console.log(
  `The first ${numbers.length} composite numbers are: ${numbers.join(", ")}`,
);
```

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