Closed lff5 closed 2 years ago
Duplicate of #29 Duplicate of #71 Duplicate of #56 Seems like a needed feature! Even pull request pending: https://github.com/functoid/binary-parser/commit/6ceacd4cbc8f093ad4f4a5b60ddebf07901ed953
I am going with .nest() workaround so all formatting is handled in upper layer in single function. Fortunately nest varName "" does not produce new level of depth - keeping the nest layer transparent.
var test_sub = new Parser()
.nest("", {
type: new Parser().endianess('little')
.bit2("param1")
.bit3("my_param")
.bit2("the_other_param2"),
formatter: function(arg) {
console.log(arg);
arg.param1 = arg.param1*arg.param1;
return arg;
},
});
Hi all.
I would like to format multi-bit field result. I define formatter function but as seen from the generated code, formatter is called before the actual bitfield is extracted. Same holds true for assert function for bitfields. I assume formatting was not intended functionality for bitfields, but for my payload parsers it would be super-duper awesome.
Original code:
Compiled code:
Console output: