From 6cca7360eb9027e1544f7513df7da4684061ef7e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 7 Jun 2018 16:50:33 +0200 Subject: Reduce bundle sizes --- client/src/assets/player/utils.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'client/src/assets/player/utils.ts') diff --git a/client/src/assets/player/utils.ts b/client/src/assets/player/utils.ts index ce7aaea2a..4eaf53720 100644 --- a/client/src/assets/player/utils.ts +++ b/client/src/assets/player/utils.ts @@ -1,4 +1,5 @@ import { is18nLocale, isDefaultLocale } from '../../../../shared/models/i18n/i18n' +import { VideoFile } from '../../../../shared/models/videos' function toTitleCase (str: string) { return str.charAt(0).toUpperCase() + str.slice(1) @@ -97,6 +98,28 @@ function copyToClipboard (text: string) { document.body.removeChild(el) } +function videoFileMaxByResolution (files: VideoFile[]) { + let max = files[0] + + for (let i = 1; i < files.length; i++) { + const file = files[i] + if (max.resolution.id < file.resolution.id) max = file + } + + return max +} + +function videoFileMinByResolution (files: VideoFile[]) { + let min = files[0] + + for (let i = 1; i < files.length; i++) { + const file = files[i] + if (min.resolution.id > file.resolution.id) min = file + } + + return min +} + export { toTitleCase, buildVideoLink, @@ -107,6 +130,8 @@ export { saveMuteInStore, buildVideoEmbed, getStoredMute, + videoFileMaxByResolution, + videoFileMinByResolution, copyToClipboard, isMobile, bytes -- cgit v1.2.3