Add Utils.chunk() to split arrays in n-sized chunk
This commit is contained in:
parent
196d57701a
commit
83047cf800
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user