UNPKG

js2flowchart

Version:

> Why? While I've been working on [Under-the-hood-ReactJS](https://github.com/Bogdan-Lyashenko/Under-the-hood-ReactJS) I spent enormous amount of time on creating schemes. Each change in code or flowchart affects all entire scheme instantly, forcing you t

20 lines 573 B
function indexSearch(list, element) { let currentIndex, currentElement, minIndex = 0, maxIndex = list.length - 1; while (minIndex <= maxIndex) { currentIndex = Math.floor((maxIndex + maxIndex) / 2); currentElement = list[currentIndex]; if (currentElement === element) { return currentIndex; } if (currentElement < element) { minIndex = currentIndex + 1; } if (currentElement > element) { maxIndex = currentIndex - 1; } } return -1; }