Dejvino's Curriculum Vitae
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

11 řádky
364 B

  1. export function partition<T>(array: T[]|undefined, entriesPerRow: number): T[][] {
  2. return array ? array.reduce((accumulator: T[][], current: T, index) => {
  3. if (index % entriesPerRow == 0) {
  4. accumulator[accumulator.length] = [current]
  5. } else {
  6. accumulator[accumulator.length - 1]
  7. }
  8. return accumulator
  9. }, []) : []
  10. }