diff options
author | Sam Potts <sam@potts.es> | 2018-04-03 22:30:29 +1000 |
---|---|---|
committer | Sam Potts <sam@potts.es> | 2018-04-03 22:30:29 +1000 |
commit | 91d192dd7c27edb877669d4e331ce8e8856e4cb6 (patch) | |
tree | d79bbc71baa0addcaa8bb7366593fbee2c69b956 /src/js/utils.js | |
parent | b1e3abc795c6af0e4c215cc228c2d944942f3ce9 (diff) | |
download | plyr-91d192dd7c27edb877669d4e331ce8e8856e4cb6.tar.lz plyr-91d192dd7c27edb877669d4e331ce8e8856e4cb6.tar.xz plyr-91d192dd7c27edb877669d4e331ce8e8856e4cb6.zip |
YouTube speed menu fix
Diffstat (limited to 'src/js/utils.js')
-rw-r--r-- | src/js/utils.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/js/utils.js b/src/js/utils.js index dd1466df..2ec57a50 100644 --- a/src/js/utils.js +++ b/src/js/utils.js @@ -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 |