{"id":15592076,"url":"https://github.com/derhuerst/flatten-overlapping-ranges","last_synced_at":"2025-04-15T05:31:08.163Z","repository":{"id":57238071,"uuid":"118280653","full_name":"derhuerst/flatten-overlapping-ranges","owner":"derhuerst","description":"Flatten overlapping ranges into a sequence of sections.","archived":false,"fork":false,"pushed_at":"2020-08-01T11:01:09.000Z","size":15,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T16:21:22.446Z","etag":null,"topics":["flatten","intervals","merge","overlap","ranges"],"latest_commit_sha":null,"homepage":"https://github.com/derhuerst/flatten-overlapping-ranges#flatten-overlapping-ranges","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/derhuerst.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-20T21:05:11.000Z","updated_at":"2022-02-10T07:01:44.000Z","dependencies_parsed_at":"2022-08-26T14:04:33.496Z","dependency_job_id":null,"html_url":"https://github.com/derhuerst/flatten-overlapping-ranges","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fflatten-overlapping-ranges","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fflatten-overlapping-ranges/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fflatten-overlapping-ranges/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fflatten-overlapping-ranges/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/derhuerst","download_url":"https://codeload.github.com/derhuerst/flatten-overlapping-ranges/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501882,"owners_count":21114682,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flatten","intervals","merge","overlap","ranges"],"created_at":"2024-10-02T23:54:16.268Z","updated_at":"2025-04-15T05:31:08.133Z","avatar_url":"https://github.com/derhuerst.png","language":"JavaScript","funding_links":["https://patreon.com/derhuerst"],"categories":[],"sub_categories":[],"readme":"# flatten-overlapping-ranges\n\n**Flatten overlapping ranges into a sequence of sections.**\n\n```\n---A---     ---C---\n  -----B------\n     --D--\n```\n\n```\n-- --- -- --- -- -- -----\nA  A   A         C  C\n   B   B  B   B  B\n       D  D\n```\n\n[![npm version](https://img.shields.io/npm/v/flatten-overlapping-ranges.svg)](https://www.npmjs.com/package/flatten-overlapping-ranges)\n[![build status](https://api.travis-ci.org/derhuerst/flatten-overlapping-ranges.svg?branch=master)](https://travis-ci.org/derhuerst/flatten-overlapping-ranges)\n![ISC-licensed](https://img.shields.io/github/license/derhuerst/flatten-overlapping-ranges.svg)\n[![chat on gitter](https://badges.gitter.im/derhuerst.svg)](https://gitter.im/derhuerst)\n[![support me on Patreon](https://img.shields.io/badge/support%20me-on%20patreon-fa7664.svg)](https://patreon.com/derhuerst)\n\n\n## Installing\n\n```shell\nnpm install flatten-overlapping-ranges\n```\n\n\n## Usage\n\n```js\nconst flatten = require('flatten-overlapping-ranges')\n\nconst sections = flatten([\n\t['A', 0, 7], // start a 0, length of 7\n\t['B', 2, 12],\n\t['D', 5, 5],\n\t['C', 12, 7]\n])\nconsole.log(Array.from(sections))\n```\n\n```js\n[\n\t[2, ['A']], // length of 2\n\t[3, ['A', 'B']],\n\t[2, ['A', 'B', 'D']],\n\t[3, ['B', 'D']],\n\t[2, ['B']],\n\t[2, ['C', 'B']],\n\t[5, ['c']]\n]\n```\n\nInstead 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:\n\n```js\nflatten([\n\t[{name: 'A'}, 0, 7],\n\t[{name: 'B'}, 2, 12]\n])\n```\n\n\n## Contributing\n\nIf 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).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderhuerst%2Fflatten-overlapping-ranges","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderhuerst%2Fflatten-overlapping-ranges","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderhuerst%2Fflatten-overlapping-ranges/lists"}