@@ -76,7 +76,7 @@ class ObjectId {
7676 'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'
7777 ) ;
7878 } else if ( valid && typeof id === 'string' && id . length === 24 && hasBufferType ) {
79- return new ObjectId ( new Buffer ( id , 'hex' ) ) ;
79+ return new ObjectId ( Buffer . from ( id , 'hex' ) ) ;
8080 } else if ( valid && typeof id === 'string' && id . length === 24 ) {
8181 return ObjectId . createFromHexString ( id ) ;
8282 } else if ( id != null && id . length === 12 ) {
@@ -167,7 +167,7 @@ class ObjectId {
167167 : process . pid ) % 0xffff ;
168168 const inc = this . get_inc ( ) ;
169169 // Buffer used
170- const buffer = new Buffer ( 12 ) ;
170+ const buffer = Buffer . alloc ( 12 ) ;
171171 // Encode time
172172 buffer [ 3 ] = time & 0xff ;
173173 buffer [ 2 ] = ( time >> 8 ) & 0xff ;
@@ -278,7 +278,7 @@ class ObjectId {
278278 * @return {ObjectId } return the created ObjectId
279279 */
280280 static createFromTime ( time ) {
281- const buffer = new Buffer ( [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ) ;
281+ const buffer = Buffer . from ( [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ) ;
282282 // Encode time into first 4 bytes
283283 buffer [ 3 ] = time & 0xff ;
284284 buffer [ 2 ] = ( time >> 8 ) & 0xff ;
@@ -304,7 +304,7 @@ class ObjectId {
304304 }
305305
306306 // Use Buffer.from method if available
307- if ( hasBufferType ) return new ObjectId ( new Buffer ( string , 'hex' ) ) ;
307+ if ( hasBufferType ) return new ObjectId ( Buffer . from ( string , 'hex' ) ) ;
308308
309309 // Calculate lengths
310310 const array = new _Buffer ( 12 ) ;
0 commit comments