# discontinuous-range

> for adding, subtracting, and indexing discontinuous ranges of numbers

Latest version **1.0.3** (published 2024-11-14) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 35/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2024-11-14 |
| First published | 2014-09-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 13 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | David Tudury |
| Maintainers | dtudury |
| Keywords | discontinuous, range, set |

## Links

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

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2024-11-14
- 1.0.2 — 2024-11-14
- 1.0.1 — 2024-11-14
- 1.0.0 — 2014-09-16

## README

discontinuous-range
===================

```
DiscontinuousRange(1, 10).subtract(4, 6); // [ 1-3, 7-10 ]
```

this is a pretty simple module, but it exists to service another project
so this'll be pretty lacking documentation. 
reading the test to see how this works may help.  otherwise, here's an example
that I think pretty much sums it up


### Example
```
var all_numbers = new DiscontinuousRange(1, 100); //[ 1-100 ]
var bad_numbers = DiscontinuousRange(13).add(8).add(60,80); //[8, 13, 60-80]
var good_numbers = all_numbers.clone().subtract(bad_numbers);
console.log(good_numbers.toString()); //[ 1-7, 9-12, 14-59, 81-100 ]
var random_good_number = good_numbers.index(Math.floor(Math.random() * good_numbers.length));
```

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