alexbol99 / flatten-interval-tree

Interval binary search tree
MIT License
41 stars 21 forks source link

Add generic types for intervaltree #19

Closed subdavis closed 3 years ago

subdavis commented 3 years ago

Adds generic types so that the interval tree value type can be specified in the constructor.

Right now, this type definition isn't especially useful because it cant enforce custom types.

Make note of the T = any in the intervaltree def: this is done for backward compatibility: users who rely on the any type should not notice any changes when updating to this type def.

Trivial example:

const intervalTree = new IntervalTree<string>();
intervalTree.insert([0, 100], {}); // TYPE ERROR
alexbol99 commented 3 years ago

Hi @subdavis , Excellent suggestion. I merged your pull request. Available in the release v1.0.13. Thank you for your contribution to this project Alex