serialize method
Implementation
BsonBinary serialize(var object, [int offset = 0]) {
if (!((object is Map) || (object is List))) {
throw Exception('Invalid value for BSON serialize: $object');
}
var bsonObject = BsonObject.bsonObjectFrom(object);
var buffer = BsonBinary(bsonObject.byteLength() + offset);
buffer.offset = offset;
BsonObject.bsonObjectFrom(object).packValue(buffer);
return buffer;
}