-
Looks like I2C.readFrom already returns an Uint8Array, so I think you are doing a double allocation.
Not sure, but I think your memory usage might be smaller with just:var data = read(register, length);
Or not, or might not even be measurable, if that allocation is just in a small function, and the GC frees up memory...
-
is the same size as
var data; data.set(read(register, length));```
This function is used quite often in the examples:
https://www.espruino.com/Reference#l_ArrayBufferView_set
Just a code snipped:
I didn't try/check your code in detail, but I'd suggest to define data (or b) as Uint8Array.