-
-
Save wulucxy/5d8cc33b3508003e52700921e81bcfbf to your computer and use it in GitHub Desktop.
#javascript
This file contains hidden or 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
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