diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-23 09:48:48 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-07-24 10:58:16 +0200 |
commit | a8b666e9f1ed002230869606308749614390c82f (patch) | |
tree | 9fb59c3f322cf77ac6b37cc27e2c726f0e10c7ba /server/helpers | |
parent | 7663e55a2cc46a413bceee2787d48902b15ae642 (diff) | |
download | PeerTube-a8b666e9f1ed002230869606308749614390c82f.tar.gz PeerTube-a8b666e9f1ed002230869606308749614390c82f.tar.zst PeerTube-a8b666e9f1ed002230869606308749614390c82f.zip |
Add plugin static files cache
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/utils.ts | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index 94ceb15e0..1464b1477 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts | |||
@@ -19,18 +19,14 @@ async function generateRandomString (size: number) { | |||
19 | return raw.toString('hex') | 19 | return raw.toString('hex') |
20 | } | 20 | } |
21 | 21 | ||
22 | interface FormattableToJSON { toFormattedJSON (args?: any) } | 22 | interface FormattableToJSON<U, V> { toFormattedJSON (args?: U): V } |
23 | function getFormattedObjects<U, T extends FormattableToJSON> (objects: T[], objectsTotal: number, formattedArg?: any) { | 23 | function getFormattedObjects<U, V, T extends FormattableToJSON<U, V>> (objects: T[], objectsTotal: number, formattedArg?: U) { |
24 | const formattedObjects: U[] = [] | 24 | const formattedObjects = objects.map(o => o.toFormattedJSON(formattedArg)) |
25 | |||
26 | objects.forEach(object => { | ||
27 | formattedObjects.push(object.toFormattedJSON(formattedArg)) | ||
28 | }) | ||
29 | 25 | ||
30 | return { | 26 | return { |
31 | total: objectsTotal, | 27 | total: objectsTotal, |
32 | data: formattedObjects | 28 | data: formattedObjects |
33 | } as ResultList<U> | 29 | } as ResultList<V> |
34 | } | 30 | } |
35 | 31 | ||
36 | const getServerActor = memoizee(async function () { | 32 | const getServerActor = memoizee(async function () { |