@@ -21,8 +21,6 @@ export interface ObjectIdExtended {
21
21
$oid : string ;
22
22
}
23
23
24
- const kId = Symbol ( 'id' ) ;
25
-
26
24
/**
27
25
* A class representation of the BSON ObjectId type.
28
26
* @public
@@ -39,7 +37,7 @@ export class ObjectId extends BSONValue {
39
37
static cacheHexString : boolean ;
40
38
41
39
/** ObjectId Bytes @internal */
42
- private [ kId ] ! : Uint8Array ;
40
+ private buffer ! : Uint8Array ;
43
41
/** ObjectId hexString cache @internal */
44
42
private __id ?: string ;
45
43
@@ -108,13 +106,13 @@ export class ObjectId extends BSONValue {
108
106
if ( workingId == null || typeof workingId === 'number' ) {
109
107
// The most common use case (blank id, new objectId instance)
110
108
// Generate a new id
111
- this [ kId ] = ObjectId . generate ( typeof workingId === 'number' ? workingId : undefined ) ;
109
+ this . buffer = ObjectId . generate ( typeof workingId === 'number' ? workingId : undefined ) ;
112
110
} else if ( ArrayBuffer . isView ( workingId ) && workingId . byteLength === 12 ) {
113
111
// 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 ) ;
115
113
} else if ( typeof workingId === 'string' ) {
116
114
if ( workingId . length === 24 && checkForHexRegExp . test ( workingId ) ) {
117
- this [ kId ] = ByteUtils . fromHex ( workingId ) ;
115
+ this . buffer = ByteUtils . fromHex ( workingId ) ;
118
116
} else {
119
117
throw new BSONError (
120
118
'input must be a 24 character hex string, 12 byte Uint8Array, or an integer'
@@ -134,11 +132,11 @@ export class ObjectId extends BSONValue {
134
132
* @readonly
135
133
*/
136
134
get id ( ) : Uint8Array {
137
- return this [ kId ] ;
135
+ return this . buffer ;
138
136
}
139
137
140
138
set id ( value : Uint8Array ) {
141
- this [ kId ] = value ;
139
+ this . buffer = value ;
142
140
if ( ObjectId . cacheHexString ) {
143
141
this . __id = ByteUtils . toHex ( value ) ;
144
142
}
@@ -240,7 +238,9 @@ export class ObjectId extends BSONValue {
240
238
}
241
239
242
240
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
+ ) ;
244
244
}
245
245
246
246
if ( typeof otherId === 'string' ) {
0 commit comments