INNER CODE UNIT · TypeScript

binaryBytes

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

    const binaryBytes = ByteUtils.allocate(array.byteLength + 2);
    binaryBytes[0] = Binary.VECTOR_TYPE.Float32;
    binaryBytes[1] = 0;

    const floatBytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
    binaryBytes.set(floatBytes, 2);

    if (NumberUtils.isBigEndian) ByteUtils.swap32(new Uint8Array(binaryBytes.buffer, 2));

    const bin = new this(binaryBytes, this.SUBTYPE_VECTOR);
    validateBinaryVector(bin);
    return bin;
  }

  /**
   * Constructs a Binary representing a packed bit Vector.
   *
   * Use `fromBits` to pack an array of 1s and 0s.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…