Browse Source

implement util.splitList() with slice() instead of splice()

umbrel
kenshin-samourai 4 years ago
parent
commit
6b22848190
  1. 8
      lib/util.js

8
lib/util.js

@ -50,13 +50,9 @@ class Util {
* Splits a list into a list of lists each with maximum length LIMIT
*/
static splitList(list, limit) {
if (list.length <= limit)
return [list]
const lists = []
while (list.length) {
lists.push(list.splice(0, limit))
}
for (let i=0; i < list.length; i += limit)
lists.push(list.slice(i, i+limit))
return lists
}

Loading…
Cancel
Save