X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcore-utils.ts;h=e1c15a6ebf1aa08c2c86b22af1448d970aa211f1;hb=f2eb23cd87cf32b8fe545178143b5f49e06a58da;hp=b1f5d9610ba28d6e4cbf996cf0000fbd4d1835c1;hpb=c2777c1dfe688c8fab1ef2fed50e360100fa9198;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts index b1f5d9610..e1c15a6eb 100644 --- a/server/helpers/core-utils.ts +++ b/server/helpers/core-utils.ts @@ -41,6 +41,7 @@ const timeTable = { } export function parseDurationToMs (duration: number | string): number { + if (duration === null) return null if (typeof duration === 'number') return duration if (typeof duration === 'string') { @@ -175,6 +176,16 @@ function pageToStartAndCount (page: number, itemsPerPage: number) { return { start, count: itemsPerPage } } +function mapToJSON (map: Map) { + const obj: any = {} + + for (const [ k, v ] of map) { + obj[k] = v + } + + return obj +} + function buildPath (path: string) { if (isAbsolute(path)) return path @@ -263,6 +274,7 @@ export { sha256, sha1, + mapToJSON, promisify0, promisify1,