diff options
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 () { |