Skip to content

Latest commit

 

History

History
16 lines (11 loc) · 2.34 KB

ideas.md

File metadata and controls

16 lines (11 loc) · 2.34 KB

Here are some ideas for additional features that could be added to the bisect function:

  1. Custom comparator: Allow the user to provide a custom comparator function that will be used to compare elements in the array. This would enable bisecting on more complex data types that cannot be compared using the built-in > and < operators.

  2. Return all indices: Currently, the bisect function returns only the index of the first occurrence of the target in the array. It could be useful to also return the indices of all occurrences of the target in the array.

  3. Reverse search: Currently, the bisect function assumes that the array is sorted in ascending order. It could be useful to have an option to search a sorted array in descending order as well.

  4. Range search: Allow the user to specify a range of indices to search within the array, instead of searching the entire array. This could improve the performance of the function on very large arrays.

  5. Error tolerance: For arrays that contain floating-point numbers, it may be useful to allow for some degree of error tolerance in the comparison of elements. This would help avoid situations where the target is not found due to rounding errors.

  6. Currently, the comparator option only works for certain types of data (namely, numbers and objects that can be compared with deepEquality). It might be useful to add support for other types of data, such as strings or dates. This could be done by adding more type constraints to the Comparator type.

  7. You might consider adding some validation for the input values of the comparator function. For example, you could throw an error if the comparator doesn't return a valid number.

  8. You could add a feature to allow the bisect function to work with non-ascending order, in addition to the existing ascending and descending options.

  9. Another possible feature would be to add an option for the bisect function to return all occurrences of the target element in the array, instead of just the first occurrence. This could be useful in cases where the array contains duplicates of the target element.

  10. The current implementation uses the deepEquality function to compare objects for equality. Depending on the use case, it might be more appropriate to use a different comparison function, such as one that only compares certain fields of the objects.