Add static BSONValue.isX cross vm context instance of check methods

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: BSON
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      How are you using Mongo? What version of the server and driver are you using?

      I am using the BSON library in an environment that imports from commonjs and es module versions of the BSON package. Or I'm using the BSON library in an environment with cross realm boundaries such that instanceof is unreliable.

      What is the feature/improvement you would like?

      I would like a static method much like Array.isArray for each BSONValue class that returns a boolean for whether or not the input is an instance of the corresponding BSON class.

      // ex.
      ObjectId.isObjectId(oid) // true
      Int32.isInt32(oid) // false
      

      What use case would this feature/improvement enable?

      It would provide a public API way to identify a bson type at runtime, the current method is to use the semi-private _bsontype property.

            Assignee:
            Unassigned
            Reporter:
            Neal Beeken
            None
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: