function flatten(...arrays) {
  return arrays.reduce((output, current) => current ? [...output, ...current] : output, []);
}
function arrayToDictionary(array, getKey) {
  return array.reduce((dictionary, currentValue) => {
    const key = typeof getKey === "function" ? getKey(currentValue) : currentValue[getKey];
    return { ...dictionary, [key]: currentValue };
  }, {});
}
function arrayToArrayDictionary(array, getKey) {
  return array.reduce((dictionary, currentValue) => {
    const key = getKey(currentValue);
    return {
      ...dictionary,
      [key]: [...dictionary[key] || [], currentValue]
    };
  }, {});
}
function arrayToArraysByKey(array, getKey) {
  const dictionary = arrayToArrayDictionary(array, getKey);
  return Object.keys(dictionary).map((key) => ({
    key,
    items: dictionary[key]
  }));
}
function findLastIndex(array, callback) {
  return array.reduce((output, item, index) => callback(item) ? index : output, -1);
}
function reIndex(array, startFrom) {
  if (startFrom === 0) {
    return [...array];
  }
  return [...array.slice(startFrom), ...array.slice(0, startFrom)];
}
function repeat(count, mapper) {
  const array = [];
  for (let i = 0; i < count; i += 1) {
    array.push(i);
  }
  return array.map(mapper);
}
function getOverallIndex(innerIndex, outerIndex, arrays) {
  return arrays.slice(0, outerIndex).reduce((output, array) => array.items.length + output, 0) + innerIndex;
}
function getAtOverallIndex(index, arrays) {
  let totalIndex = 0;
  for (const array of arrays) {
    const newIndex = totalIndex + array.items.length;
    if (index < newIndex) {
      return array.items[index - totalIndex];
    }
    totalIndex = newIndex;
  }
  return void 0;
}
function uniq(array) {
  const result = [];
  for (const item of array) {
    if (!result.includes(item)) {
      result.push(item);
    }
  }
  return result;
}
export {
  arrayToArrayDictionary,
  arrayToArraysByKey,
  arrayToDictionary,
  findLastIndex,
  flatten,
  getAtOverallIndex,
  getOverallIndex,
  reIndex,
  repeat,
  uniq
};
//# sourceMappingURL=arrays.js.map
