import { ParsedApplicationInfo } from "../../../vendor/kernel/core/WasmParser" ; export interface AppGrid { id : string ; apps : ParsedApplicationInfo [ ] ; } export param { Application [ ] } apps param { number } amountPerGrid returns { AppGrid [ ] } export default function sortAppsInGrids ( apps , amountPerGrid ) { const result = [ ] ; let gridItem = { id : Math . random ( ) . toString ( ) , apps : [ ] , } ; apps . forEach ( ( app ) => { gridItem . apps . push ( app ) ; if ( gridItem . apps . length === amountPerGrid ) { result . push ( gridItem ) ; gridItem = { id : Math . random ( ) . toString ( ) , apps : [ ] , } ; } } ) ; if ( gridItem . apps . length ) { result . push ( gridItem ) ; } return result ; }