Utilities for operate over intervals
$ npm install --save @redtea/intervals
import { includes, merge, clip, select } from "@redtea/intervals"
// or
// const intervals = require("@redtea/intervals");
// or
// in html <script src="https://unpkg.com/@redtea/intervals"></script>
// 1 in [2, 3]
includes(2, 1, 3); // true
// 4 not in [1, 3]
includes(4, 1, 3); // false
merge([[1,3],[1,2],[4,5]]); // [[1,3],[4,5]]
merge([[1,3],[1,2],[4,5]], 1); // [[1,5]
clip([[1,3],[5,7],[9,11]], 1, 11) // [[3,5], [7,9]]
clip([[2,3],[5,6]], 1, 7) // [[1,2],[3,5],[6,7]]
select([[1,2]], 1, 2) // [[1, 2]]
select([[0,2],[1,3]], 1, 2) // [[0, 2], [1, 3]]
Test if number in interval [start, end] and return result.
Merge intervals that intersect or where distance between intervals less then maxDistance. Always return new list.
Exclude intervals intervals from interval [start, end]. Always return new list.
Select all intervals that intersect or inside of interval [start, end]. Always return new list.