Skip to content

Instantly share code, notes, and snippets.

@h-jennings
Last active October 24, 2020 14:14
Show Gist options
  • Save h-jennings/cc24318389a80d5420edf3f1b6037809 to your computer and use it in GitHub Desktop.
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)
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