aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/core-utils
diff options
context:
space:
mode:
Diffstat (limited to 'shared/core-utils')
-rw-r--r--shared/core-utils/common/object.ts5
-rw-r--r--shared/core-utils/videos/bitrate.ts2
-rw-r--r--shared/core-utils/videos/index.ts1
-rw-r--r--shared/core-utils/videos/uuid.ts32
4 files changed, 6 insertions, 34 deletions
diff --git a/shared/core-utils/common/object.ts b/shared/core-utils/common/object.ts
index 88d6b7514..49d209819 100644
--- a/shared/core-utils/common/object.ts
+++ b/shared/core-utils/common/object.ts
@@ -10,6 +10,10 @@ function pick <O extends object, K extends keyof O> (object: O, keys: K[]): Pick
10 return result 10 return result
11} 11}
12 12
13function getKeys <O extends object, K extends keyof O> (object: O, keys: K[]): K[] {
14 return (Object.keys(object) as K[]).filter(k => keys.includes(k))
15}
16
13function sortObjectComparator (key: string, order: 'asc' | 'desc') { 17function sortObjectComparator (key: string, order: 'asc' | 'desc') {
14 return (a: any, b: any) => { 18 return (a: any, b: any) => {
15 if (a[key] < b[key]) { 19 if (a[key] < b[key]) {
@@ -26,5 +30,6 @@ function sortObjectComparator (key: string, order: 'asc' | 'desc') {
26 30
27export { 31export {
28 pick, 32 pick,
33 getKeys,
29 sortObjectComparator 34 sortObjectComparator
30} 35}
diff --git a/shared/core-utils/videos/bitrate.ts b/shared/core-utils/videos/bitrate.ts
index c1891188f..30d22df09 100644
--- a/shared/core-utils/videos/bitrate.ts
+++ b/shared/core-utils/videos/bitrate.ts
@@ -1,4 +1,4 @@
1import { VideoResolution } from "@shared/models" 1import { VideoResolution } from '@shared/models'
2 2
3type BitPerPixel = { [ id in VideoResolution ]: number } 3type BitPerPixel = { [ id in VideoResolution ]: number }
4 4
diff --git a/shared/core-utils/videos/index.ts b/shared/core-utils/videos/index.ts
index 8f6736d39..620e3a716 100644
--- a/shared/core-utils/videos/index.ts
+++ b/shared/core-utils/videos/index.ts
@@ -1,3 +1,2 @@
1export * from './bitrate' 1export * from './bitrate'
2export * from './privacy' 2export * from './privacy'
3export * from './uuid'
diff --git a/shared/core-utils/videos/uuid.ts b/shared/core-utils/videos/uuid.ts
deleted file mode 100644
index f3c80e046..000000000
--- a/shared/core-utils/videos/uuid.ts
+++ /dev/null
@@ -1,32 +0,0 @@
1import short, { uuid } from 'short-uuid'
2
3const translator = short()
4
5function buildUUID () {
6 return uuid()
7}
8
9function uuidToShort (uuid: string) {
10 if (!uuid) return uuid
11
12 return translator.fromUUID(uuid)
13}
14
15function shortToUUID (shortUUID: string) {
16 if (!shortUUID) return shortUUID
17
18 return translator.toUUID(shortUUID)
19}
20
21function isShortUUID (value: string) {
22 if (!value) return false
23
24 return value.length === translator.maxLength
25}
26
27export {
28 buildUUID,
29 uuidToShort,
30 shortToUUID,
31 isShortUUID
32}