mongodb/js-bson — pull request #71 by pandaiolo (2014-02-23 11:11:20+00:00)
Title: Fix, an object with type ObjectID should be able to convert itself 

I propose this small addition to ObjectID, so that when used as a caster, it does not throw an exception.

Example :

var myObjectID = new ObjectID();
var idWithUnknownType = myObjectId;
// Some code later, use ObjectID() to force the type
idWithUnknownType = ObjectID(idWithUnknownType);

The above code works with basic javascript types, like Object, String, Number, but not ObjectID

MongoDB BSON ObjectID is used in many third party code that deals with serialization, database callbacks, string IDs, etc, which would make it handy if the ObjectID type can cast itslef, in many cases.

I included a test case for this behaviour, not sure if it's at the right place.

The fact that the whole test suite ran without a glitch let me propose this pullback. Let me know if there is a reason why ObjectID cannot be enhanced with this behaviour. Thanks !