-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
It's sometimes useful to be able to know a relative offset of a specific field of a Struct.
Currently this works for me, but I would expect to see such API available out-of-the box ;)
Thanks!
r.Struct.prototype.offsetOf = function(field) {
let keys = Object.keys(this.fields);
let offset = 0;
for (let i=0; i<keys.length; i++) {
let key = keys[i];
if (key == field) {
return offset;
}
offset += this.fields[key].size();
}
return -1;
}Metadata
Metadata
Assignees
Labels
No labels