Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-5144

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

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

      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 Unassigned
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: