(
command: WriteProtocolMessageType,
description: { agreedCompressor?: CompressorName; zlibCompressionLevel?: number }
)
| 161 | * also serializes the command to BSON. |
| 162 | */ |
| 163 | export 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 |
nothing calls this directly
no test coverage detected