From 0628157fe9662fdb2b6fa658b8b53fe684c013ce Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 29 Dec 2021 14:44:58 +0100 Subject: Move uuid stuff in extra utils Since it requires an external dependency --- shared/core-utils/common/object.ts | 5 +++++ shared/core-utils/videos/bitrate.ts | 2 +- shared/core-utils/videos/index.ts | 1 - shared/core-utils/videos/uuid.ts | 32 -------------------------------- 4 files changed, 6 insertions(+), 34 deletions(-) delete mode 100644 shared/core-utils/videos/uuid.ts (limited to 'shared/core-utils') 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 (object: O, keys: K[]): Pick return result } +function getKeys (object: O, keys: K[]): K[] { + return (Object.keys(object) as K[]).filter(k => keys.includes(k)) +} + function sortObjectComparator (key: string, order: 'asc' | 'desc') { return (a: any, b: any) => { if (a[key] < b[key]) { @@ -26,5 +30,6 @@ function sortObjectComparator (key: string, order: 'asc' | 'desc') { export { pick, + getKeys, sortObjectComparator } 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 @@ -import { VideoResolution } from "@shared/models" +import { VideoResolution } from '@shared/models' type BitPerPixel = { [ id in VideoResolution ]: number } 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 @@ export * from './bitrate' export * from './privacy' -export * 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 @@ -import short, { uuid } from 'short-uuid' - -const translator = short() - -function buildUUID () { - return uuid() -} - -function uuidToShort (uuid: string) { - if (!uuid) return uuid - - return translator.fromUUID(uuid) -} - -function shortToUUID (shortUUID: string) { - if (!shortUUID) return shortUUID - - return translator.toUUID(shortUUID) -} - -function isShortUUID (value: string) { - if (!value) return false - - return value.length === translator.maxLength -} - -export { - buildUUID, - uuidToShort, - shortToUUID, - isShortUUID -} -- cgit v1.2.3