"use strict";

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


/**
 * It sorts the array, and then looks just at the first and last items
 * taken from https://stackoverflow.com/questions/1916218/find-the-longest-common-starting-substring-in-a-set-of-strings
 * @param {[]} array
 */
function sharedStartOfArray(array) {
  var sortedArray = array.concat().sort();
  var firstItem = sortedArray[0];
  var lastItem = sortedArray[sortedArray.length - 1];
  var i = 0;
  while (i < firstItem.length && firstItem.charAt(i) === lastItem.charAt(i)) {
    i += 1;
  }return firstItem.substring(0, i);
}