Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/service-provider-core/src/printable-bson.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions packages/service-provider-core/src/printable-bson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,17 @@ 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,
...options,
// 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);
}
Expand Down