index.ts387 chars17 linesThe splitIntoChunks function takes in two arguments: the array to be split and the desired size of each chunk. It then creates an empty array to hold the resulting chunks and sets an initial index variable to zero.
The function then enters a while loop that continues to slice segments from the input array and push them to the chunks array until the end of the array is reached. The size of each slice is determined by the chunkSize parameter passed to the function.
Once the while loop has completed executing, the function simply returns the chunks array with all the resulting chunks of the original array.
gistlibby LogSnag