Skip to content

Unexpected result from intersecting ranges #4

@mattes3

Description

@mattes3

I have tried this:

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);

As a result, I get

result [ [ 20, 24, { color: 'yellow' } ] ]

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions