|
|
@ -101,20 +101,14 @@ class Util { |
|
|
|
* Splits a list into a list of lists each with maximum length LIMIT |
|
|
|
*/ |
|
|
|
static splitList(list, limit) { |
|
|
|
if (list.length <= limit) { |
|
|
|
if (list.length <= limit) |
|
|
|
return [list] |
|
|
|
} else { |
|
|
|
const lists = [] |
|
|
|
// How many lists to create?
|
|
|
|
const count = Math.ceil(list.length / limit) |
|
|
|
// How many elements per list (max)?
|
|
|
|
const els = Math.ceil(list.length / count) |
|
|
|
|
|
|
|
for (let i=0; i < count; i++) { |
|
|
|
lists.push(list.slice(i * els, (i+1) * els)) |
|
|
|
} |
|
|
|
return lists |
|
|
|
|
|
|
|
const lists = [] |
|
|
|
while (list.length) { |
|
|
|
lists.push(list.splice(0, limit)) |
|
|
|
} |
|
|
|
return lists |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|