Created
January 26, 2023 21:43
-
-
Save dwblair/cc651bcb3bd11f13840c074c80bd924b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('hello') | |
import struct from "../struct.mjs"; | |
function toArrayBuffer(buf) { | |
const ab = new ArrayBuffer(buf.length); | |
const view = new Uint8Array(ab); | |
for (let i = 0; i < buf.length; ++i) { | |
view[i] = buf[i]; | |
} | |
return ab; | |
} | |
//let s = struct("<10sHHb") | |
let s = struct("<6f") | |
//let record = s.pack("Raymond ", 4658, 264, 8) | |
//let record = '982f854090673f43bc35bb410028cf4188577d44646ccf41'.match(/(..)/g).map(b => parseInt(b, 16)) | |
let record = toArrayBuffer(Buffer.from("982f854090673f43bc35bb410028cf4188577d44646ccf41", "hex")); | |
let results = s.unpack(record) | |
console.log(results) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment