@@ -21,8 +21,6 @@ export interface ObjectIdExtended {
2121 $oid : string ;
2222}
2323
24- const kId = Symbol ( 'id' ) ;
25-
2624/**
2725 * A class representation of the BSON ObjectId type.
2826 * @public
@@ -39,7 +37,7 @@ export class ObjectId extends BSONValue {
3937 static cacheHexString : boolean ;
4038
4139 /** ObjectId Bytes @internal */
42- private [ kId ] ! : Uint8Array ;
40+ private buffer ! : Uint8Array ;
4341 /** ObjectId hexString cache @internal */
4442 private __id ?: string ;
4543
@@ -108,13 +106,13 @@ export class ObjectId extends BSONValue {
108106 if ( workingId == null || typeof workingId === 'number' ) {
109107 // The most common use case (blank id, new objectId instance)
110108 // Generate a new id
111- this [ kId ] = ObjectId . generate ( typeof workingId === 'number' ? workingId : undefined ) ;
109+ this . buffer = ObjectId . generate ( typeof workingId === 'number' ? workingId : undefined ) ;
112110 } else if ( ArrayBuffer . isView ( workingId ) && workingId . byteLength === 12 ) {
113111 // If intstanceof matches we can escape calling ensure buffer in Node.js environments
114- this [ kId ] = ByteUtils . toLocalBufferType ( workingId ) ;
112+ this . buffer = ByteUtils . toLocalBufferType ( workingId ) ;
115113 } else if ( typeof workingId === 'string' ) {
116114 if ( workingId . length === 24 && checkForHexRegExp . test ( workingId ) ) {
117- this [ kId ] = ByteUtils . fromHex ( workingId ) ;
115+ this . buffer = ByteUtils . fromHex ( workingId ) ;
118116 } else {
119117 throw new BSONError (
120118 'input must be a 24 character hex string, 12 byte Uint8Array, or an integer'
@@ -134,11 +132,11 @@ export class ObjectId extends BSONValue {
134132 * @readonly
135133 */
136134 get id ( ) : Uint8Array {
137- return this [ kId ] ;
135+ return this . buffer ;
138136 }
139137
140138 set id ( value : Uint8Array ) {
141- this [ kId ] = value ;
139+ this . buffer = value ;
142140 if ( ObjectId . cacheHexString ) {
143141 this . __id = ByteUtils . toHex ( value ) ;
144142 }
@@ -240,7 +238,9 @@ export class ObjectId extends BSONValue {
240238 }
241239
242240 if ( ObjectId . is ( otherId ) ) {
243- return this [ kId ] [ 11 ] === otherId [ kId ] [ 11 ] && ByteUtils . equals ( this [ kId ] , otherId [ kId ] ) ;
241+ return (
242+ this . buffer [ 11 ] === otherId . buffer [ 11 ] && ByteUtils . equals ( this . buffer , otherId . buffer )
243+ ) ;
244244 }
245245
246246 if ( typeof otherId === 'string' ) {
0 commit comments