diff --git a/packages/service-provider-core/src/printable-bson.spec.ts b/packages/service-provider-core/src/printable-bson.spec.ts index 911fd34888..a49f78e6c8 100644 --- a/packages/service-provider-core/src/printable-bson.spec.ts +++ b/packages/service-provider-core/src/printable-bson.spec.ts @@ -108,6 +108,12 @@ describe('BSON printers', function () { ).to.equal('Binary.fromPackedBits(new Uint8Array([ 1, 2, 3 ]))'); }); + it('formats PackedBits correctly with padding', function () { + expect( + inspect(bson.Binary.fromPackedBits(new Uint8Array([1, 2, 3]), 7)) + ).to.equal('Binary.fromPackedBits(new Uint8Array([ 1, 2, 3 ]), 7)'); + }); + it('formats Float32Array correctly', function () { expect( inspect( diff --git a/packages/service-provider-core/src/printable-bson.ts b/packages/service-provider-core/src/printable-bson.ts index 874c1de871..81525f50ea 100644 --- a/packages/service-provider-core/src/printable-bson.ts +++ b/packages/service-provider-core/src/printable-bson.ts @@ -59,7 +59,8 @@ const binaryVectorInspect = function ( maxArrayLength: utilInspect.defaultOptions.maxArrayLength, }) )}))`; - case BSON.Binary.VECTOR_TYPE.PackedBit: + case BSON.Binary.VECTOR_TYPE.PackedBit: { + const paddingInfo = this.buffer[1] === 0 ? '' : `, ${this.buffer[1]}`; return `Binary.fromPackedBits(new Uint8Array(${removeTypedArrayPrefixFromInspectResult( utilInspect(this.toPackedBits(), { depth, @@ -67,7 +68,8 @@ const binaryVectorInspect = function ( // These arrays can be very large, so would prefer to use the default options instead. maxArrayLength: utilInspect.defaultOptions.maxArrayLength, }) - )}))`; + )})${paddingInfo})`; + } default: return binaryInspect.call(this, depth, options); }