X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcore-utils.ts;h=49eee7c591323f0fca9eb17e0807002d7ff01c0a;hb=c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e;hp=2cecea4500bc1d64c41693a72064f89c5a920ded;hpb=7cd1b12c19d0589d1d692ed0571ca0800f028aea;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts index 2cecea450..49eee7c59 100644 --- a/server/helpers/core-utils.ts +++ b/server/helpers/core-utils.ts @@ -1,7 +1,7 @@ /* eslint-disable no-useless-call */ /* - Different from 'utils' because we don't not import other PeerTube modules. + Different from 'utils' because we don't import other PeerTube modules. Useful to avoid circular dependencies. */ @@ -175,6 +175,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 +273,7 @@ export { sha256, sha1, + mapToJSON, promisify0, promisify1,