text: const CustomError = require("../extensions/custom-error");
  
  module.exports = function transform(arr) {
    if (!Array.isArray(arr)) {
      throw new Error;
    }
  
    if (arr === undefined || arr.length === 0) {
      return [];
    }
    let newArr = [];
    //
    for (i = 0; i < arr.length; i++) {
          if (arr[i] === '--double-next') {
                  if (i < arr.length - 1) {
          newArr.push(arr[i + 1]);
        }
  
          } else if (arr[i] === '--double-prev') {
        if (i !== 0) {
         if (i > 1 && arr[i - 2] === '--discard-next') {
            continue;
          }
          newArr.push(arr[i - 1]);
                }
      } else if (arr[i] === '--discard-next') {
        if (i < arr.length - 1) {
          i++
        }
  
      } else if (arr[i] === '--discard-prev') {
        if (i !== 0) {
          if (i > 1 && arr[i - 2] === '--discard-next') {
            continue;
  
          }
                  newArr.pop()
        }
      } else {
              newArr.push(arr[i])
          }
    }
    return newArr;
  };
  