mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2026-09-03 20:53:09 -05:00
Move uuid stuff in extra utils
Since it requires an external dependency
This commit is contained in:
@@ -10,6 +10,10 @@ function pick <O extends object, K extends keyof O> (object: O, keys: K[]): Pick
|
||||
return result
|
||||
}
|
||||
|
||||
function getKeys <O extends object, K extends keyof O> (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
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { VideoResolution } from "@shared/models"
|
||||
import { VideoResolution } from '@shared/models'
|
||||
|
||||
type BitPerPixel = { [ id in VideoResolution ]: number }
|
||||
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
export * from './bitrate'
|
||||
export * from './privacy'
|
||||
export * from './uuid'
|
||||
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user