rangr is a tool to manage ranges and sets. It's inspired from the LeetCode's Merge Interval problem.
⚠️ NOT ready for production use.
Usage
; ;console.logrange.toString;// [1,6],[8,10],[15,18] range.add;console.logrange.toString;// [1,6],[8,20]
Features
Array output
To get ranges as an array, use .toArray()
method provided.
Example:
;; // [ [ 1, 6 ] ]
Iterable output
To get ranges as an iterable, use .toIterable()
method provided.
Example:
;; rangeIterator.next; // { value: [ 1, 6 ], done: false }rangeIterator.next; // { value: undefined, done: true }
Support for ESM and CommonJS
rangr supports both ECMAScript Modules and CommonJS using Conditional Exports provided by Node.js.
CommonJS
const Rangr = ;
ESM
;
Contributions
The package is not very performant in managing th ranges and lacks a rich API. Contributions in the form of issues and PRs are welcome! 🙌🏽
Install
npm i rangr
Test
npm test