The purpose of this function is to make it possible to convert the object
{"": 1, "": 2}
for sort keys returned by compound sort specifications into the array
[1, 2]
which can be meaningfully interacted with via JavaScript. The duplicate empty string field names in the object form are otherwise hidden by the first one. It should be possible to use this function on Objects which have non-duplicate and non-empty field names as well. In those cases, it can be thought of as a function similar to Object.values() but one that actually works for BSONInfo instances.
We can model this function off the bsonWoCompare() and bsonBinaryEqual() functions where the mongo shell will define a bsonObjToArray() global function that uses ObjectWrapper::toBSON() to convert/extract the argument as a BSONObj. It should then use ValueReader::fromBSONArray() to convert the BSONObj into a JavaScript Array.