package com.base.scanqr.utils

object CollectionEx {

    fun <T> List<T>.addStepElements(beanStep: Int = 3, newElement: () -> T): MutableList<T> {
        val chunkedList = this.chunked(beanStep)
        val newList = mutableListOf<T>()
        chunkedList.forEach {
            newList.addAll(it)
            if (it.size == beanStep) {
                newList.add(newElement())
            }
        }
        return newList
    }
}