function DecodeBitfield(dummy, size) {
  if (size > 32) {
    this.errstr = "INVALID_BITFIELD_SIZE";
    return {result: false};
  }

  let bitfieldSize = Math.floor((size + 7) / 8);
  let dummyBitlength = dummy.length;
  if (dummyBitlength !== bitfieldSize) {
    this.errstr = "INVALID_BITFIELD_SIZE";
    return {result: false};
  }

  let bitfield = 0;
  let dummyAs32Bit = Uint32Array.from(dummy);
  // let one = new Uint8Array([1]);
  // let oneAs64Bit = BigUint64Array.from(one);

  for (let i = 0; i < bitfieldSize; i++) {
    bitfield = bitfield | (dummyAs32Bit[i] << (8*i));
  }

  let mask = (0x01 << size) - 1
  if((bitfield & mask) != bitfield) {
    this.errstr = "INVALID_BIT_RANGE";
    return {result: false};
  }

  return {result: true, bitfield: bitfield};
}
Implemented from bitcoin-abc
https://github.com/Bitcoin-ABC/bitcoin-abc/blob/f8cbc0e2b439aa4030430a7b1ecbdafede0dd072/src/script/bitfield.cpp
@param {*} dummy
@param {*} size