# Generated by detroit
# See https://github.com/bourbonut/detroit/tree/main/api_maker

from functools import partial
from operator import is_not

class bisector:
    def __init__(self, content="bisector"):
        self.content = content

    def __repr__(self):
        return self.content

    def __str__(self):
        return self.content

    def __call__(self, *args):
        arguments = ", ".join(map(repr, args))
        return f"{self}({arguments})"

    def right(self, array=None, x=None, lo=None, hi=None):
        """
        .. code:: javascript

            d3.bisector((d) => d.Date).right(aapl, new Date("2014-01-02")) // 163

        Like bisectRight, but using this bisector’s accessor. The code above finds the index of
        the row immediately following Jan. 2, 2014 in the aapl sample dataset.

        See more informations `here <https://d3js.org/d3-array/bisect#bisector_right>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (array, x, lo, hi))))
        return bisector(content=f"{self.content}.right({arguments})")


    def left(self, array=None, x=None, lo=None, hi=None):
        """
        .. code:: javascript

            d3.bisector((d) => d.Date).left(aapl, new Date("2014-01-02")) // 162

        Like bisectLeft, but using this bisector’s accessor. The code above finds the index of
        the row for Jan. 2, 2014 in the aapl sample dataset.

        See more informations `here <https://d3js.org/d3-array/bisect#bisector_left>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (array, x, lo, hi))))
        return bisector(content=f"{self.content}.left({arguments})")


    def center(self, array=None, x=None, lo=None, hi=None):
        """
        .. code:: javascript

            d3.bisector((d) => d.Date).center(aapl, new Date("2013-12-31")) // 161

        Returns the index of the closest value to x in the given sorted array. This expects
        that the bisector’s accessor returns a quantitative value, or that the bisector’s
        comparator returns a signed distance; otherwise, this method is equivalent to
        bisector.left. The arguments lo (inclusive) and hi (exclusive) may be used to specify a
        subset of the array which should be considered; by default the entire array is used.

        See more informations `here <https://d3js.org/d3-array/bisect#bisector_center>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (array, x, lo, hi))))
        return bisector(content=f"{self.content}.center({arguments})")

