debianize-mobilizon/js/src/utils/object.ts
Thomas Citharel 4144e9ffd0
Introduce group basic federation, event new page and notifications
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2020-06-03 16:01:26 +02:00

6 lines
221 B
TypeScript

export function buildObjectCollection<T, U>(collection: T[] | undefined, builder: new (p: T) => U) {
if (!collection || Array.isArray(collection) === false) return [];
return collection.map((v) => new builder(v));
}