-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
int24 and uint24 support #93
Comments
I will add support for var parser = new Parser().array("uint24", {
type: "uint8",
length: 3,
formatter: function(arr) {
return arr[2] << 16 | arr[1] << 8 | arr[0];
}
});
var parser = new Parser().array("int24", {
type: "uint8",
length: 3,
formatter: function(arr) {
var val = arr[2] << 16 | arr[1] << 8 | arr[0];
return (val > 0x7fffff) ? 0xff000000 | val : val;
}
}); |
Aha! I had a feeling there'd be a way to work around it but just didn't know how to even start doing it with the library as this sort of thing isn't really my forte or area of expertise. @keichi you're awesome, will use this till its in the package - thanks heaps!! ❤️ 👍 |
Hi @keichi, just come across this again and wondering if the Looks like I also have a use case for // <Buffer f9 59 a6 1a 57 c8 0f d3 00 48 01 a9>
let a = buffer.readIntBE(0, 3);
let b = buffer.readIntBE(3, 3);
console.log({ a, b }); // { a: -435802, b: 1726408 } I assume it doesn't work because these are big-edian int values? Is there another way to work around this using the library? In the mean time I'm just creating two objects and merging them before returning from my helper function 😅 |
Is it possible for the package to add support for
.int24()
and.uint24()
?Since you can't sequence more than 4 bytes using
.bit24()
I'm in a bit of a pickle with a buffer I'd like to decode..int24()
If this isn't possible, can someone direct me to a package that is similar to this but supports
int24()
?Thanks 👍
The text was updated successfully, but these errors were encountered: