* Chunk elements in the array by size * * when the array cannot be chunked evenly by size, the last chunk will be * filled with the remaining elements * * @example * chunkArray(['a','b', 'c', 'd', 'e'], 2) // returns [['a','b'], ['c', 'd'], ['e']]
( array: Array<T>, size: number, )
| 31 | * chunkArray(['a','b', 'c', 'd', 'e'], 2) // returns [['a','b'], ['c', 'd'], ['e']] |
| 32 | */ |
| 33 | function chunkArray<T extends { label: string; value: unknown }>( |
| 34 | array: Array<T>, |
| 35 | size: number, |
| 36 | ): Array<Array<T>> { |
| 37 | if (size < 1) return [] |
| 38 | let i = 0 |
| 39 | const result: Array<Array<T>> = [] |
| 40 | while (i < array.length) { |
| 41 | result.push(array.slice(i, i + size)) |
| 42 | i = i + size |
| 43 | } |
| 44 | return result |
| 45 | } |
| 46 | |
| 47 | const Expander = (props: { expanded: boolean }) => { |
| 48 | const theme = useTheme() |
no outgoing calls
no test coverage detected
searching dependent graphs…