function splice(array, startIndex, nb) {
  for (var _len2 = arguments.length, elements = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
    elements[_key2 - 3] = arguments[_key2];
  }

  if (nb === undefined && arguments.length === 2) nb = array.length - startIndex;else if (nb === null || nb === undefined) nb = 0;else if (isNaN(+nb)) throw new Error("argument nb " + nb + " can not be parsed into a number!");
  nb = Math.max(0, nb); // Solving startIndex

  if (_type["default"]["function"](startIndex)) startIndex = index(array, startIndex);
  if (_type["default"].object(startIndex)) startIndex = index(array, function (e) {
    return compare(e, startIndex);
  }); // Positive index

  if (startIndex >= 0) return array.slice(0, startIndex).concat(elements).concat(array.slice(startIndex + nb)); // Negative index

  return array.slice(0, array.length + startIndex).concat(elements).concat(array.slice(array.length + startIndex + nb));
}
Non-mutative version of the splice array method.

@param  {array}    array        - The array to splice.
@param  {integer}  startIndex   - The start index.
@param  {integer}  nb           - Number of elements to remove.
@param  {...mixed} elements     - Elements to append after splicing.
@return {array}                 - The spliced array.