Add Utils.chunk() to split arrays in n-sized chunk

This commit is contained in:
miruka 2020-06-29 10:52:43 -04:00
parent 196d57701a
commit 83047cf800

View File

@ -99,6 +99,17 @@ QtObject {
} }
function chunk(array, chunkSize) {
const chunks = []
for (let i = 0; i < array.length; i += chunkSize) {
chunks.push(array.slice(i, i + chunkSize))
}
return chunks
}
function isEmptyObject(obj) { function isEmptyObject(obj) {
return Object.entries(obj).length === 0 && obj.constructor === Object return Object.entries(obj).length === 0 && obj.constructor === Object
} }