ProductList fix chunkInefficient
This commit is contained in:
parent
e9a18f5dce
commit
fdd8fedbae
1 changed files with 9 additions and 3 deletions
|
|
@ -120,12 +120,18 @@ export default defineComponent({
|
|||
methods: {
|
||||
chunkInefficient(products: Array<TypeProduct>, chunkSize: number):Array<Array<TypeProduct>> {
|
||||
const out:Array<Array<TypeProduct>> = [];
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
let row: Array<TypeProduct> = [];
|
||||
|
||||
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<string, string> = {}, localeToUse: string | null = null): string {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue