aboutsummaryrefslogtreecommitdiffstats
path: root/lib/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils.ts')
-rw-r--r--lib/utils.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/utils.ts b/lib/utils.ts
index a805f343..7a663c60 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -168,3 +168,9 @@ export function formatReceipt(items, currency) {
}
export let t = ({ language = "en" }) => locales[language];
+
+export let chunk = (array, chunkSize) => array.reduce((all, one, i) => {
+ const chunkIndex = Math.floor(i / chunkSize);
+ (all[chunkIndex] = all[chunkIndex] || []).push(one);
+ return all;
+}, []);