(array, chunkSize)
| 43 | } |
| 44 | |
| 45 | function chunk(array, chunkSize) { |
| 46 | const result = []; |
| 47 | let batch = []; |
| 48 | for (let index = 0; index < array.length; index++) { |
| 49 | const element = array[index]; |
| 50 | batch.push(element); |
| 51 | if (batch.length === chunkSize) { |
| 52 | result.push(batch); |
| 53 | batch = []; |
| 54 | } |
| 55 | } |
| 56 | if (batch.length > 0) { |
| 57 | result.push(batch); |
| 58 | } |
| 59 | return result; |
| 60 | } |
| 61 | |
| 62 | function unique(array) { |
| 63 | return Array.from(new Set(array)); |
no outgoing calls
no test coverage detected