Last active
October 24, 2020 14:14
-
-
Save h-jennings/cc24318389a80d5420edf3f1b6037809 to your computer and use it in GitHub Desktop.
function that creates a group of arrays with length limit given an array and a max array length (number)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createArrayGroups( | |
data: any[], | |
maxArrayLength: number | |
): (any | any[])[] { | |
let array = [...data]; | |
let groups: (any | any[])[] = []; | |
do { | |
groups.push(array.splice(0, maxArrayLength)); | |
} while (array.length > 0); | |
return groups; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment