param chunkSize param array export function inChunksOf < TElement > ( chunkSize , array ) { const result = [ ] ; const arr = [ ... array ] ; while ( arr . length ) { result . push ( arr . splice ( 0 , chunkSize ) ) ; } return result ; }