export const ab2str = (buf: ArrayBuffer): string => {
  return String.fromCharCode.apply(null, new Int8Array(buf));
};

export const str2ab = (str: string): ArrayBuffer => {
  var buf = new ArrayBuffer(str.length);
  var bufView = new Int8Array(buf);
  for (var i = 0, strLen = str.length; i < strLen; i++) {
    bufView[i] = str.charCodeAt(i);
  }
  return buf;
};
