text: import { NotImplementedError } from '../extensions/index.js';
  
  /**
   * Create transformed array based on the control sequences that original
   * array contains
   * 
   * @param {Array} arr initial array
   * @returns {Array} transformed array
   * 
   * @example
   * 
   * transform([1, 2, 3, '--double-next', 4, 5]) => [1, 2, 3, 4, 4, 5]
   * transform([1, 2, 3, '--discard-prev', 4, 5]) => [1, 2, 4, 5]
   * 
   */
  export default function transform(arr) {
    if (!Array.isArray(arr)) throw new Error("'arr' parameter must be an instance of the Array!");
    let initial = arr.slice();
  
    for (let i = 0; i < initial.length; i++) {
      switch (initial[i]) {
        case '--discard-next':
          if (initial[i + 1] !== undefined) {
            initial.splice(i + 1, 1);
          }
          break;
        case '--discard-prev':
          if (initial[i - 1] !== undefined) {
            initial.splice(i - 1, 1);
          }
          break;
        case '--double-next':
          if (initial[i + 1] !== undefined) {
            initial.splice(i + 1, 0, initial[i + 1]);
          }
          break;
        case '--double-prev':
          if (initial[i - 1] !== undefined) {
            initial.splice(i - 1, 0, initial[i - 1]);
            i++;
          }
          break;
      }
    }
  
    return initial.filter(item => item !== '--discard-next' && item !== '--discard-prev' && item !== '--double-next' && item !== '--double-prev');
  };
  