# flatten-overlapping-ranges

> Flatten overlapping ranges into a sequence of sections.

Latest version **1.0.1** (published 2019-05-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install flatten-overlapping-ranges
pnpm add flatten-overlapping-ranges
yarn add flatten-overlapping-ranges
bun add flatten-overlapping-ranges
```

## 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 | 1.0.1 |
| Published | 2019-05-28 |
| First published | 2018-01-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 0 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Jannis R |
| Maintainers | derhuerst |
| Keywords | ranges, overlap, sections, flatten, merge, intersect |

## Links

- npm: https://www.npmjs.com/package/flatten-overlapping-ranges
- Repository: https://github.com/derhuerst/flatten-overlapping-ranges
- Issues: https://github.com/derhuerst/flatten-overlapping-ranges/issues
- npm.io page: https://npm.io/package/flatten-overlapping-ranges

## Recent versions

- 1.0.1 (latest) — 2019-05-28
- 1.0.0 — 2019-04-24
- 0.2.0 — 2019-04-24
- 0.1.1 — 2018-01-21
- 0.1.0 — 2018-01-20

## README

# flatten-overlapping-ranges

**Flatten overlapping ranges into a sequence of sections.**

```
---A---     ---C---
  -----B------
     --D--
```

```
-- --- -- --- -- -- -----
A  A   A         C  C
   B   B  B   B  B
       D  D
```

[![npm version](https://img.shields.io/npm/v/flatten-overlapping-ranges.svg)](https://www.npmjs.com/package/flatten-overlapping-ranges)
[![build status](https://api.travis-ci.org/derhuerst/flatten-overlapping-ranges.svg?branch=master)](https://travis-ci.org/derhuerst/flatten-overlapping-ranges)
![ISC-licensed](https://img.shields.io/github/license/derhuerst/flatten-overlapping-ranges.svg)
[![chat on gitter](https://badges.gitter.im/derhuerst.svg)](https://gitter.im/derhuerst)
[![support me on Patreon](https://img.shields.io/badge/support%20me-on%20patreon-fa7664.svg)](https://patreon.com/derhuerst)


## Installing

```shell
npm install flatten-overlapping-ranges
```


## Usage

```js
const flatten = require('flatten-overlapping-ranges')

const sections = flatten([
	['A', 0, 7], // start a 0, length of 7
	['B', 2, 12],
	['D', 5, 5],
	['C', 12, 7]
])
console.log(Array.from(sections))
```

```js
[
	[2, ['A']], // length of 2
	[3, ['A', 'B']],
	[2, ['A', 'B', 'D']],
	[3, ['B', 'D']],
	[2, ['B']],
	[2, ['C', 'B']],
	[5, ['c']]
]
```

Instead of strings as range IDs, you can use anything a [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) works with:

```js
flatten([
	[{name: 'A'}, 0, 7],
	[{name: 'B'}, 2, 12]
])
```


## Contributing

If you have a question or have difficulties using `flatten-overlapping-ranges`, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to [the issues page](https://github.com/derhuerst/flatten-overlapping-ranges/issues).

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