@DrAzzy yes, and you can actually do it on an existing buffer, so for instance:
var a=new Uint8Array(12); var f = new Float32Array(a.buffer,0,2); f[0] = ...; f[1] = ...; (new Uint32Array(a.buffer,8,1))[0] = ...; console.log(a);
I guess you could do:
AT24.prototype.aToN=function(a){return (new Uint32Array((new Uint8Array(a)).buffer))[0];}
And another nice one - although you don't use sToA:
function stoA(s) { var a = new Uint8Array(s.length); a.set(s); // I don't think passing a string into set is standard JS though! return a; }
@Gordon started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
@DrAzzy yes, and you can actually do it on an existing buffer, so for instance:
I guess you could do:
And another nice one - although you don't use sToA: