/**
 * Utilities to work with resolving data.
 */ export class ResolverUtils { /**
     * Groups given entities by a given ids.
     */ static groupByMany < T > ( originalIds , entities , property ) { const group = originalIds . reduce ( ( group , id ) => { group [ id ] = [ ] ; return group ; } , { } as any ) ; entities . forEach ( entity => { const value = property instanceof Function ? property ( entity ) : property ; if ( value instanceof Array ) { value . forEach ( propertyId => { if ( group [ propertyId ] ) group [ propertyId ] . push ( entity ) ; } ) ; } } ) ; return originalIds . map ( id => group [ id ] ) ; } }