1.0.1 • Published 4 years ago

overlapping-ranges-layout v1.0.1

Weekly downloads
5
License
ISC
Repository
github
Last release
4 years ago

overlapping-ranges-layout

overlapping-ranges-layout

npm version build status ISC-licensed minimum Node.js version chat with me on Gitter support me on Patreon

Installation

npm install overlapping-ranges-layout

Usage

const computeLayout = require('overlapping-ranges-layout')

// see also the flatten-overlapping-ranges package
// ---A---
//   -----B------
//      --C--
//         ----D---
const sections = [
	[2, ['A'               ]],
	[3, ['A', 'B'          ]],
	[2, ['A', 'B', 'C'     ]],
	[1, [     'B', 'C'     ]],
	[2, [     'B', 'C', 'D']],
	[1, [     'B',      'D']],
	[2, [               'D']]
]

const layout = computeLayout(sections)
console.log(layout)
[
	[2, ['A'           ]],
	[3, ['A',  'B'     ]],
	[2, ['A',  'B', 'C']],
	[1, [null, 'B', 'C']],
	[2, ['D',  'B', 'C']],
	[1, ['D',  'B'     ]],
	[2, ['D'           ]]
]

Contributing

If you have a question or need support using overlapping-ranges-layout, 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.