From fdd8fedbae35a785d200c963237efcafda751f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Fri, 2 Feb 2024 11:09:17 +0100 Subject: [PATCH] ProductList fix chunkInefficient --- components/ProductList.vue | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/ProductList.vue b/components/ProductList.vue index 074ab76..863c312 100644 --- a/components/ProductList.vue +++ b/components/ProductList.vue @@ -120,12 +120,18 @@ export default defineComponent({ methods: { chunkInefficient(products: Array, chunkSize: number):Array> { const out:Array> = []; - // eslint-disable-next-line @typescript-eslint/no-unused-vars + let row: Array = []; + products.forEach((elem: TypeProduct, i: number) => { - if (i % chunkSize) { - out.push(products.slice(i, i + chunkSize)); + row.push(elem); + if (i % chunkSize && row.length) { + out.push(row); + row = []; } }); + if (row.length) { + out.push(row); + } return out; }, t(text: string, params: Record = {}, localeToUse: string | null = null): string {