Skip to content

Instantly share code, notes, and snippets.

@lucasltv
Created April 30, 2021 12:28
Show Gist options
  • Save lucasltv/0480aec2a7c4d30b54b89d76b6fb82b8 to your computer and use it in GitHub Desktop.
Save lucasltv/0480aec2a7c4d30b54b89d76b6fb82b8 to your computer and use it in GitHub Desktop.
Chunke JSON Array Data
export function chunkData(array: unknown[], chunk = 10) {
let i, j;
const newArray = [];
for (i = 0, j = array.length; i < j; i += chunk) {
newArray.push(array.slice(i, i + chunk));
}
return newArray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment