code: function serializeCommand(self, command, callback) {
    const originalCommandBuffer = command.toBin();
  
    // Check whether we and the server have agreed to use a compressor
    const shouldCompress = !!self.options.agreedCompressor;
    if (!shouldCompress || !canCompress(command)) {
      return callback(null, originalCommandBuffer);
    }
  
    // Transform originalCommandBuffer into OP_COMPRESSED
    const concatenatedOriginalCommandBuffer = Buffer.concat(originalCommandBuffer);
    const messageToBeCompressed = concatenatedOriginalCommandBuffer.slice(MESSAGE_HEADER_SIZE);
  
    // Extract information needed for OP_COMPRESSED from the uncompressed message
    const originalCommandOpCode = concatenatedOriginalCommandBuffer.readInt32LE(12);
  
    // Compress the message body
    compress(self, messageToBeCompressed, function(err, compressedMessage) {
      if (err) return callback(err, null);
  
      // Create the msgHeader of OP_COMPRESSED
      const msgHeader = Buffer.alloc(MESSAGE_HEADER_SIZE);
      msgHeader.writeInt32LE(
        MESSAGE_HEADER_SIZE + COMPRESSION_DETAILS_SIZE + compressedMessage.length,
        0
      ); // messageLength
      msgHeader.writeInt32LE(command.requestId, 4); // requestID
      msgHeader.writeInt32LE(0, 8); // responseTo (zero)
      msgHeader.writeInt32LE(opcodes.OP_COMPRESSED, 12); // opCode
  
      // Create the compression details of OP_COMPRESSED
      const compressionDetails = Buffer.alloc(COMPRESSION_DETAILS_SIZE);
      compressionDetails.writeInt32LE(originalCommandOpCode, 0); // originalOpcode
      compressionDetails.writeInt32LE(messageToBeCompressed.length, 4); // Size of the uncompressed compressedMessage, excluding the MsgHeader
      compressionDetails.writeUInt8(compressorIDs[self.options.agreedCompressor], 8); // compressorID
  
      return callback(null, [msgHeader, compressionDetails, compressedMessage]);
    });
  }
docs: Prepare the buffer that Pool.prototype.write() uses to send to the server