struct-compile
Version:
Create a JavaScript class from a C structure
8 lines (7 loc) • 339 B
JavaScript
export function accessorFromParams({ endianness, signed, length, customKey, action }) {
let key = customKey ?? (length == 64 ? 'BigInt' : 'Int');
if (!signed && key == 'BigInt') {
key = 'BigUInt';
}
return `${action}${length == 64 ? '' : (signed ? '' : 'U')}${key}${customKey ? '' : length}${length > 8 ? endianness : ''}`;
};