binary-parser
binary-parser copied to clipboard
Choice keyString returns entire string
Choices seem to be broken in some instances, even though tag is int8
I have not fully tested, however I think it may have something to do with strict mode.
Working replacement
Object.keys(options.choices).forEach(async (keyid) => {
const key = parseInt(keyid, 10);
const value = key
if (isNaN(key)) {
console.log(`Choice key "${keyid}" is not a number.`);
}
if (typeof value === "string" &&
!aliasRegistry.has(value) &&
!(value in PRIMITIVE_SIZES)) {
throw new Error(`Choice type "${value}" is unkown.`);
}
})
keyString returns entire object, not just the index ID.
for (const keyString in options.choices) {
const key = parseInt(keyString, 10);
const value = options.choices[key];
if (isNaN(key)) {
throw new Error(`Choice key "${keyString}" is not a number.`);
}
if (typeof value === "string" &&
!aliasRegistry.has(value) &&
!(value in PRIMITIVE_SIZES)) {
throw new Error(`Choice type "${value}" is unkown.`);
}
Could you describe how it's broken and provide a minimal reproducible example?
Closing due to inactivity.