"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getArrayWithDefault = getArrayWithDefault;
exports.updateArrayWithDefault = updateArrayWithDefault;

function updateArrayWithDefault(array, defaultoptions = []) {
  const index = array.indexOf('...');

  if (index === -1) {
    return array;
  }

  const newArray = [...array];
  newArray.splice(index, 1, ...defaultoptions);
  return newArray;
}

const isEqualVal = (a, b) => a === b;

function getArrayWithDefault(array, defaultoptions = [], isEqual = isEqualVal) {
  const index = array.indexOf('...');

  if (index === -1) {
    return array;
  }

  const filteredDefaultOptions = defaultoptions.filter(v => !array.some(v1 => isEqual(v, v1)));
  const newArray = [...array];
  newArray.splice(index, 1, ...filteredDefaultOptions);
  return newArray;
}