mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
get api libs from bower
This commit is contained in:
parent
def418714f
commit
f36e664503
97 changed files with 16860 additions and 197 deletions
43
dashboard-ui/bower_components/hls.js/src/utils/binary-search.js
vendored
Normal file
43
dashboard-ui/bower_components/hls.js/src/utils/binary-search.js
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
var BinarySearch = {
|
||||
/**
|
||||
* Searches for an item in an array which matches a certain condition.
|
||||
* This requires the condition to only match one item in the array,
|
||||
* and for the array to be ordered.
|
||||
*
|
||||
* @param {Array} list The array to search.
|
||||
* @param {Function} comparisonFunction
|
||||
* Called and provided a candidate item as the first argument.
|
||||
* Should return:
|
||||
* > -1 if the item should be located at a lower index than the provided item.
|
||||
* > 1 if the item should be located at a higher index than the provided item.
|
||||
* > 0 if the item is the item you're looking for.
|
||||
*
|
||||
* @return {*} The object if it is found or null otherwise.
|
||||
*/
|
||||
search: function(list, comparisonFunction) {
|
||||
var minIndex = 0;
|
||||
var maxIndex = list.length - 1;
|
||||
var currentIndex = null;
|
||||
var currentElement = null;
|
||||
|
||||
while (minIndex <= maxIndex) {
|
||||
currentIndex = (minIndex + maxIndex) / 2 | 0;
|
||||
currentElement = list[currentIndex];
|
||||
|
||||
var comparisonResult = comparisonFunction(currentElement);
|
||||
if (comparisonResult > 0) {
|
||||
minIndex = currentIndex + 1;
|
||||
}
|
||||
else if (comparisonResult < 0) {
|
||||
maxIndex = currentIndex - 1;
|
||||
}
|
||||
else {
|
||||
return currentElement;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = BinarySearch;
|
Loading…
Add table
Add a link
Reference in a new issue