brucemcpherson / desktopliberation

hosting for desktop liberation google plus community
30 stars 1 forks source link

Iterator magic – Splitting an array into chunks #130

Open brucemcpherson opened 2 years ago

brucemcpherson commented 2 years ago

It’s a pretty common requirement, especially when you’re posting to an API, to split an array of data into manageable chunks, and most often the solution is to make an array of arrays – with each one being up to a maximum size. That’s fine, but we can also make an iterator.

Let’s take a look at how these approaches differ, and take a look into iterators – a very interesting addition to Apps Script as a result of v8.

https://ramblings.mcpher.com/gassnippets2/iterator-magic-splitting-an-array-into-chunks/