title: Unpack a C struct on browser?
body: <h1>EDIT</h1>
  <p>I found this:</p>
  <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays</a></p>
  <p>Basically if I have something like this:</p>
  <pre><code>struct someStruct {
    unsigned long id;
    char username[16];
    float amountDue;
  };
  </code></pre>
  <p>on client side I can do:</p>
  <pre><code>var ws = new WebSocket(&quot;ws://URI&quot;);
  ws.binaryType = &quot;arraybuffer&quot;;
  
  ws.onmessage = function (e) {
      var buffer = e.data;
      var data_view = new DataView(buffer);
      
      // ... read the data into the buffer ...
      
      var idView = data_view.getUint32(0);
      var usernameView = data_view.getUint32(4);
      var amountDueView = data_view.getFloat32(20);
  };
  </code></pre>
  <p>The problem is that I want to convert them to normal Javascript objects (numbers, strings etc).</p>
  <h1>Original question</h1>
  <p>I would send data via websocket packed using a C struct, and unpack on browser using Javascript.</p>
  <p>I know modules exists for node.js, but I can't find nothing client-side.</p>