MCPcopy
hub / github.com/mongodb/node-mongodb-native / compressCommand

Function compressCommand

src/cmap/wire_protocol/compression.ts:163–176  ·  view source on GitHub ↗
(
  command: WriteProtocolMessageType,
  description: { agreedCompressor?: CompressorName; zlibCompressionLevel?: number }
)

Source from the content-addressed store, hash-verified

161 * also serializes the command to BSON.
162 */
163export async function compressCommand(
164 command: WriteProtocolMessageType,
165 description: { agreedCompressor?: CompressorName; zlibCompressionLevel?: number }
166): Promise<Uint8Array> {
167 const finalCommand =
168 description.agreedCompressor === 'none' || !OpCompressedRequest.canCompress(command)
169 ? command
170 : new OpCompressedRequest(command, {
171 agreedCompressor: description.agreedCompressor ?? 'none',
172 zlibCompressionLevel: description.zlibCompressionLevel ?? 0
173 });
174 const data = await finalCommand.toBin();
175 return ByteUtils.concat(data);
176}
177
178/**
179 * @internal

Callers

nothing calls this directly

Calls 2

canCompressMethod · 0.80
toBinMethod · 0.45

Tested by

no test coverage detected