Skip to content

Instantly share code, notes, and snippets.

@wulucxy
Last active May 3, 2022 08:01
Show Gist options
  • Save wulucxy/5d8cc33b3508003e52700921e81bcfbf to your computer and use it in GitHub Desktop.
Save wulucxy/5d8cc33b3508003e52700921e81bcfbf to your computer and use it in GitHub Desktop.
#javascript
const largeRecipientList = new Array(2000).fill().map((_, idx) => `customer${idx}@nowhere.com`)
// largeRecipientList is an array of email addresses
const recipientLimit = 100
const batches = largeRecipientList.reduce((batches, r) => {
const lastBatch = batches[batches.length - 1]
if(lastBatch.length < recipientLimit)
lastBatch.push(r)
else
batches.push([r])
return batches
}, [[]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment