[Pas2js] Records as pure data?

Ryan Joseph ryan at thealchemistguild.com
Wed May 9 15:11:08 CEST 2018



> On May 9, 2018, at 7:38 PM, Mattias Gaertner <nc-gaertnma at netcologne.de> wrote:
> 
>> Float32Array seems to do this but it only works for a single type. I wonder if you could use Float32Array and Int8Array for example and concatenate them.
> 
> AFAIK no.

What do you think about this? Looks like it may be possible. If that works then you could pack records into bytes if you made a little helper function in the parser.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set

// create a SharedArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(8);
const uint8 = new Uint8Array(buffer);

// Copy the values into the array starting at index 3
uint8.set([1, 2, 3], 3);


Regards,
	Ryan Joseph



More information about the Pas2js mailing list