Repository navigation
bisector.center - #156
bisector.center#156
Conversation
|
And the demo https://observablehq.com/d/8581f0e7e07ee62b |
799fddd to
107631b
Compare
|
It’s clever how this uses the comparator for most of the work and only relies on the signed distance calculation at the end to choose between the two possible results, such that if an accessor is specified and the accessor doesn’t return a number, the result is NaN and this is equivalent to bisector.left. There’s a bug here with arrays of size zero and one. I’ll add a fix. |
|
Oh, and also this needs to the support the optional lo and hi arguments. |
107631b to
8aa9a13
Compare
|
I found it surprising that bisector.center returns values rather than indexes, unlike bisector.left and bisector.right. So I’ve also rewritten the code to return indexes. And I noticed that it wasn’t consistent with bisector.left in the ordinal case, so I’ve also added some more tests. |
Fixes #138.
8aa9a13 to
5b78836
Compare
fixes #138