INNER CODE UNIT · TypeScript

byteOffset

mongodb/js-bson · src/binary.ts:497

      const byteOffset = bitOffset >>> 3; // floor(bitOffset / 8)
      const bit = bits[bitOffset];

      if (bit !== 0 && bit !== 1) {
        throw new BSONError(
          `Invalid bit value at ${bitOffset}: must be 0 or 1, found ${bits[bitOffset]}`
        );
      }

      if (bit === 0) continue;

      const shift = 7 - (bitOffset % 8);
      bytes[byteOffset + 2] |= bit << shift;
    }

    return new this(bytes, Binary.SUBTYPE_VECTOR);
  }
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…