@andrew_l/toolkit 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1814,8 +1814,13 @@ function bitPack(options) {
1814
1814
  function initFields(fields) {
1815
1815
  return fields.map((field) => {
1816
1816
  if (field.bits > 32) {
1817
+ ok(
1818
+ field.take === "low",
1819
+ `Fields more than 32 bits with take 'high' not yet supported`
1820
+ );
1821
+ const highMask = Math.pow(2, field.bits - 32) - 1;
1817
1822
  return [
1818
- `var ${field.id}_high = (data['${field.name}'] / 0x100000000) | 0;`,
1823
+ `var ${field.id}_high = ((data['${field.name}'] / 0x100000000) | 0) & 0x${highMask.toString(16)};`,
1819
1824
  `var ${field.id}_low = (data['${field.name}'] >>> 0);`
1820
1825
  ].join("\n");
1821
1826
  }