YouTube speed menu fix

This commit is contained in:
Sam Potts
2018-04-03 22:30:29 +10:00
parent b1e3abc795
commit 91d192dd7c
18 changed files with 1960 additions and 900 deletions

View File

@ -746,6 +746,15 @@ const utils = {
return array.filter((item, index) => array.indexOf(item) === index);
},
// Get the closest value in an array
closest(array, value) {
if (!utils.is.array(array) || !array.length) {
return null;
}
return array.reduce((prev, curr) => Math.abs(curr - value) < Math.abs(prev - value) ? curr : prev);
},
// Get the provider for a given URL
getProviderByUrl(url) {
// YouTube