@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.cjs CHANGED
@@ -1825,8 +1825,13 @@ function bitPack(options) {
1825
1825
  function initFields(fields) {
1826
1826
  return fields.map((field) => {
1827
1827
  if (field.bits > 32) {
1828
+ ok(
1829
+ field.take === "low",
1830
+ `Fields more than 32 bits with take 'high' not yet supported`
1831
+ );
1832
+ const highMask = Math.pow(2, field.bits - 32) - 1;
1828
1833
  return [
1829
- `var ${field.id}_high = (data['${field.name}'] / 0x100000000) | 0;`,
1834
+ `var ${field.id}_high = ((data['${field.name}'] / 0x100000000) | 0) & 0x${highMask.toString(16)};`,
1830
1835
  `var ${field.id}_low = (data['${field.name}'] >>> 0);`
1831
1836
  ].join("\n");
1832
1837
  }