|
- export function partition<T>(array: T[]|undefined, entriesPerRow: number): T[][] {
- return array ? array.reduce((accumulator: T[][], current: T, index) => {
- if (index % entriesPerRow == 0) {
- accumulator[accumulator.length] = [current]
- } else {
- accumulator[accumulator.length - 1]
- }
- return accumulator
- }, []) : []
- }
|