mobilizon.chapril.org-mobil.../js/src/utils/object.ts

6 lines
221 B
TypeScript
Raw Normal View History

2019-09-02 14:35:50 +02:00
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));
}