const intersectingRanges = require("intersecting-ranges");
const colors = [
[0, 8, { color: 'red' }],
[10, 14, { color: 'brown' }],
[16, 24, { color: 'blue' }],
[20, 29, { color: 'yellow' }]
];
const result = intersectingRanges(colors, { withData: true, omitEmpty: false });
console.log('result', result);
result [ [ 20, 24, { color: 'yellow' } ] ]
I have tried this:
As a result, I get
However, I expected more because I have set
omitEmpty=false. And: Is it possible to merge the colors into an array like[ [ 20, 24, { color: ['blue', 'yellow'] } ] ]because both colors were present in the original intervals?By the way: Can you help me solve the original problem here?
https://stackoverflow.com/questions/52555253/how-do-intersect-intervals-in-javascript