Skip to content

Commit

Permalink
adopt default arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Aug 15, 2021
1 parent b1d9d3e commit c3cd01f
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/bisector.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ export default function(f) {
compare2 = (d, x) => ascending(f(d), x);
}

function left(a, x, lo, hi) {
if (lo == null) lo = 0;
if (hi == null) hi = a.length;
function left(a, x, lo = 0, hi = a.length) {
if (lo < hi) {
if (compare1(x, x) !== 0) return hi;
do {
Expand All @@ -25,9 +23,7 @@ export default function(f) {
return lo;
}

function right(a, x, lo, hi) {
if (lo == null) lo = 0;
if (hi == null) hi = a.length;
function right(a, x, lo = 0, hi = a.length) {
if (lo < hi) {
if (compare1(x, x) !== 0) return hi;
do {
Expand All @@ -39,9 +35,7 @@ export default function(f) {
return lo;
}

function center(a, x, lo, hi) {
if (lo == null) lo = 0;
if (hi == null) hi = a.length;
function center(a, x, lo = 0, hi = a.length) {
const i = left(a, x, lo, hi - 1);
return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i;
}
Expand Down

0 comments on commit c3cd01f

Please sign in to comment.