// This Source Code Form is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/

// Function decides if the current browser is capable of working with encoded streams
function isCapableOfEncodedStream() {
  return !!navigator?.userAgent?.includes("Chrome");
}
function recordToDataView(record) {
  const text = JSON.stringify(record);
  if (!text) {
    throw new Error("Invalid record");
  }
  const encoder = new TextEncoder();
  const data = encoder.encode(text);
  const dataView = new DataView(data.buffer);
  return dataView;
}

export { isCapableOfEncodedStream as i, recordToDataView as r };
