/*
 * Split array to an array fileld with chunks size of chunkSize parameter.
 */
export function chunk(array, chunkSize) {
  const result = [];
  for (let i = 0; i < array.length; i += chunkSize) {
    result.push(array.slice(i, i + chunkSize));
  }
  return result;
}
/*
 * Regular map function with offset. Array can be reordered to start
 * from different point with offset. For example, does week start from
 * Monday or Sunday.
 */
export function mapWithOffset(array, startingOffset, mapFn) {
  return array.map((_, i) => {
    const adjustedIndex = (i + startingOffset) % array.length;
    return mapFn(array[adjustedIndex]);
  });
}
