repo.or.cz
/
ProtonMail-WebClient.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Cleanup - unused files / unused exports / duplicate exports
[ProtonMail-WebClient.git]
/
packages
/
utils
/
chunk.ts
blob
0fe8d6ed9dcccb9e3cf86b77a4a5e8c7469110b6
1
/**
2
* Divide an array into sub-arrays of a fixed chunk size
3
*/
4
const chunk = <T>(list: T[] = [], size = 1) => {
5
return list.reduce<T[][]>((res, item, index) => {
6
if (index % size === 0) {
7
res.push([]);
8
}
9
res[res.length - 1].push(item);
10
return res;
11
}, []);
12
};
13
14
export default chunk;