Int32Array_as_Uint8Array.js 600 B

123456789101112131415161718
  1. import { int32_arrays } from "../data.js";
  2. import { expect } from "https://esm.sh/v126/chai@4.3.7/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs";
  3. /** @param {unknown[]} received */
  4. export const check = (received) => {
  5. for (const [i, typed_array] of int32_arrays.entries()) {
  6. expect(received[i]).to.be.an.instanceof(Uint8Array);
  7. expect(received[i]).to.deep.equal(new Uint8Array(typed_array.buffer));
  8. }
  9. };
  10. /**
  11. * @param {import("../peerjs").DataConnection} dataConnection
  12. */
  13. export const send = (dataConnection) => {
  14. for (const typed_array of int32_arrays) {
  15. dataConnection.send(typed_array);
  16. }
  17. };