Skip to content

Instantly share code, notes, and snippets.

@naramdash
Last active September 17, 2020 12:34
Show Gist options
  • Save naramdash/2c607b95d883ee9649af25d2218fc406 to your computer and use it in GitHub Desktop.
Save naramdash/2c607b95d883ee9649af25d2218fc406 to your computer and use it in GitHub Desktop.
split array to small array with maxLength
function sliceToSmallArray(acc, arr, maxLength) {
if (arr.length === 0) return acc
if (arr.length <= maxLength) return [...acc, arr]
return sliceToSmallArray([...acc, arr.slice(0, maxLength)], arr.slice(maxLength), maxLength)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment