Changed the BinarySearch component from a function to an arrow function.

Changed the BinarySearch component from a function to an arrow function.

The original component was defined using the function keyword, but I updated it to use an arrow function instead. This change provides a more concise syntax and also avoids any issues with the binding of the "this" keyword.

I have tested the updated component and verified that it works as expected.

Thanks for considering this change!
This commit is contained in:
BenLad 2023-02-20 07:55:07 +07:00 committed by GitHub
parent af08253a95
commit e17e9b095a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,7 @@ import Comparator from '../../../utils/comparator/Comparator';
* @return {number} * @return {number}
*/ */
export default function binarySearch(sortedArray, seekElement, comparatorCallback) { export default const binarySearch = (sortedArray, seekElement, comparatorCallback) => {
// Let's create comparator from the comparatorCallback function. // Let's create comparator from the comparatorCallback function.
// Comparator object will give us common comparison methods like equal() and lessThen(). // Comparator object will give us common comparison methods like equal() and lessThen().
const comparator = new Comparator(comparatorCallback); const comparator = new Comparator(comparatorCallback);