const parse = function (trace) {
  let data;
  let dir = function (ident) {
    if (ident === '=>') {
      return 'request';
    }
    if (ident === '<=') {
      return 'response';
    }
  };

  // better regex, please, start here:
  // http://scriptular.com/#%5E(%3F%3A%5Ba-z0-9%5D%7B4%7D%3A)%20((%3F%3A%5Ba-z0-9%5D%7B2%7D%20)%7B1%2C16%7D)%7C%7C%7C%7C%7C%7C%7C%7C%5B%2200a0%3A%2011%2022%2033%2044%2055%2066%2077%2088%2099%2010%2011%2012%2013%2014%2015%2016%2017%20%20%7B.%20%20%5C%22headers%5C%22%3A%20%7B%22%5D

  const traceLines = trace.split('\n');
  const dataPattern = /^(?:[a-z0-9]{4}:) ((?:[a-z0-9]{2} ){1,16})/;
  const dirPattern = /^(=>|<=)/;

  // find ASCI bytes in raw lines

  // will contain array of arrays with direction and data
  // e.g [['<=', "47 45 54 20 2f 73 68 6f 70 70 69 6e 67 2d 63 61"]]
  const asciiHexSets = [];
  let lastDir = '';

  for (const line of traceLines) {
    const dirMatch = dirPattern.exec(line);
    if (dirMatch !== null) {
      lastDir = dirMatch[0].trim();
    }

    const dataMatch = dataPattern.exec(line);
    if (dataMatch !== null) {
      data = dataMatch[1].trim();
      asciiHexSets.push([lastDir, data]);
    }
  }


  // split lines by spaces and make array of ASCII hex bytes
  const asciiHexBuffer = { request: [], response: [] };
  for (const set of asciiHexSets) {
    data = set[1];
    for (const byte of data.split(' ')) {
      asciiHexBuffer[dir(set[0])].push(byte);
    }
  }

  // convert ASCII hex to ASCII integers codes
  const asciiIntBuffer = { request: [], response: [] };
  for (dir in asciiHexBuffer) {
    const hexs = asciiHexBuffer[dir];
    for (const hex of hexs) {
      asciiIntBuffer[dir].push(parseInt(`0x${hex}`));
    }
  }

  // convert ACII codes to charactes
  const stringBuffer = { request: [], response: [] };
  for (dir in asciiIntBuffer) {
    const codes = asciiIntBuffer[dir];
    for (const code of codes) {
      stringBuffer[dir].push(String.fromCharCode(code));
    }
  }

  const output = {};
  output.request = stringBuffer.request.join('');
  output.response = stringBuffer.response.join('');
  return output;
};


const parseToString = function (trace) {
  const message = parse(trace);
  let output = '';

  const request = [];
  const requestLines = message.request.split('\r\n');
  for (var line of requestLines) {
    request.push(`> ${line}`);
  }
  output += request.join('\r\n');
  output += '\n';
  output += '\r\n';
  const response = [];
  const responseLines = message.response.split('\r\n');
  for (line of responseLines) {
    response.push(`< ${line}`);
  }
  output += response.join('\r\n');
  output += '\n';
  return output;
};


const parseBackRequestAndResponseFromString = function (string) {
  const output = {};

  const request = [];
  const stringLines = string.split('\r\n');
  for (var line of stringLines) {
    if (/^> /.test(line)) { request.push(line.replace(/^> /, '')); }
  }

  // removing trailing LF
  output.request = request.join('\r\n').replace(/\n$/, '');

  const response = [];
  for (line of stringLines) {
    if (/^< /.test(line)) { response.push(line.replace(/^< /, '')); }
  }

  // removing trailing LF
  output.response = response.join('\r\n').replace(/\n$/, '');

  return output;
};


module.exports.parseBackRequestAndResponseFromString = parseBackRequestAndResponseFromString;
module.exports.parseBack = parseBackRequestAndResponseFromString;
module.exports.parseToString = parseToString;
module.exports.parse = parse;

@@ -32,22 +32,12 @@
 %7B%0A  
-let data;%0A  le
+cons
 t di
@@ -1080,24 +1080,30 @@
 ll) %7B%0A      
+const 
 data = dataM
@@ -1302,19 +1302,33 @@
  (const 
-set
+%5Bdirection, data%5D
  of asci
@@ -1343,27 +1343,8 @@
 ) %7B%0A
-    data = set%5B1%5D;%0A
     
@@ -1410,14 +1410,17 @@
 dir(
-set%5B0%5D
+direction
 )%5D.p
@@ -1547,31 +1547,49 @@
 %5D %7D;%0A  for (
-dir in 
+const key of Object.keys(
 asciiHexBuff
@@ -1587,24 +1587,25 @@
 iiHexBuffer)
+)
  %7B%0A    const
@@ -1623,27 +1623,27 @@
 iiHexBuffer%5B
-dir
+key
 %5D;%0A    for (
@@ -1680,27 +1680,27 @@
 iiIntBuffer%5B
-dir
+key
 %5D.push(parse
@@ -1707,18 +1707,15 @@
 Int(
-%600x$%7Bhex%7D%60
+hex, 16
 ));%0A
@@ -1827,15 +1827,33 @@
 or (
-dir in 
+const key of Object.keys(
 asci
@@ -1863,16 +1863,17 @@
 tBuffer)
+)
  %7B%0A    c
@@ -1900,19 +1900,19 @@
 tBuffer%5B
-dir
+key
 %5D;%0A    f
@@ -1957,19 +1957,19 @@
 gBuffer%5B
-dir
+key
 %5D.push(S
@@ -2319,35 +2319,37 @@
 '%5Cr%5Cn');%0A  for (
-var
+const
  line of request
@@ -2542,32 +2542,38 @@
 '%5Cr%5Cn');%0A  for (
+const 
 line of response
@@ -2857,11 +2857,13 @@
 or (
-var
+const
  lin
@@ -3073,16 +3073,22 @@
 %0A  for (
+const 
 line of 

Fix lint errors found by eslint