node_modules/bson/dist/bson.browser.esm.js
/**
     * Create an ObjectId type
     *
     * @param id - Can be a 24 character hex string, 12 byte binary Buffer, or a number.
     */
Create an ObjectId type
@param id - Can be a 24 character hex string, 12 byte binary Buffer, or a number.
Create an ObjectId type @param id - Can be a 24 character hex string 12 byte binary Buffer or a number .
function ObjectId(id) {
        if (!(this instanceof ObjectId))
            return new ObjectId(id);
        if (id instanceof ObjectId) {
            this[kId] = id.id;
            this.__id = id.__id;
        }
        if (typeof id === 'object' && id && 'id' in id) {
            if ('toHexString' in id && typeof id.toHexString === 'function') {
                this[kId] = buffer_1.from(id.toHexString(), 'hex');
            }
            else {
                this[kId] = typeof id.id === 'string' ? buffer_1.from(id.id) : id.id;
            }
        }
        if (id == null || typeof id === 'number') {
            this[kId] = ObjectId.generate(typeof id === 'number' ? id : undefined);
            if (ObjectId.cacheHexString) {
                this.__id = this.id.toString('hex');
            }
        }
        if (ArrayBuffer.isView(id) && id.byteLength === 12) {
            this[kId] = ensureBuffer(id);
        }
        if (typeof id === 'string') {
            if (id.length === 12) {
                var bytes = buffer_1.from(id);
                if (bytes.byteLength === 12) {
                    this[kId] = bytes;
                }
            }
            else if (id.length === 24 && checkForHexRegExp.test(id)) {
                this[kId] = buffer_1.from(id, 'hex');
            }
            else {
                throw new TypeError('Argument passed in must be a Buffer or string of 12 bytes or a string of 24 hex characters');
            }
        }
        if (ObjectId.cacheHexString) {
            this.__id = this.id.toString('hex');
        }
    }
function ObjectId ( id ) { if ( ! ( this instanceof ObjectId ) ) return new ObjectId ( id ) ; if ( id instanceof ObjectId ) { this [ kId ] = id . id ; this . __id = id . __id ; } if ( typeof id === 'object' && id && 'id' in id ) { if ( 'toHexString' in id && typeof id . toHexString === 'function' ) { this [ kId ] = buffer_1 . from ( id . toHexString ( ) , 'hex' ) ; } else { this [ kId ] = typeof id . id === 'string' ? buffer_1 . from ( id . id ) : id . id ; } } if ( id == null || typeof id === 'number' ) { this [ kId ] = ObjectId . generate ( typeof id === 'number' ? id : undefined ) ; if ( ObjectId . cacheHexString ) { this . __id = this . id . toString ( 'hex' ) ; } } if ( ArrayBuffer . isView ( id ) && id . byteLength === 12 ) { this [ kId ] = ensureBuffer ( id ) ; } if ( typeof id === 'string' ) { if ( id . length === 12 ) { var bytes = buffer_1 . from ( id ) ; if ( bytes . byteLength === 12 ) { this [ kId ] = bytes ; } } else if ( id . length === 24 && checkForHexRegExp . test ( id ) ) { this [ kId ] = buffer_1 . from ( id , 'hex' ) ; } else { throw new TypeError ( 'Argument passed in must be a Buffer or string of 12 bytes or a string of 24 hex characters' ) ; } } if ( ObjectId . cacheHexString ) { this . __id = this . id . toString ( 'hex' ) ; } }
Create an ObjectId type
 @param id - Can be a 24 character hex string, 12 byte binary Buffer, or a number.
Create an ObjectId type @param id - Can be a 24 character hex string 12 byte binary Buffer or a number .
// Duck-typing to support ObjectId from different npm packages // The most common use case (blank id, new objectId instance) // Generate a new id // If we are caching the hex string