Dejvino's Curriculum Vitae
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

11 行
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. }