File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ var ObjectID = function ObjectID(id) {
49
49
if ( ! valid && id != null ) {
50
50
throw new Error ( "Argument passed in must be a single String of 12 bytes or a string of 24 hex characters" ) ;
51
51
} else if ( valid && typeof id == 'string' && id . length == 24 && hasBufferType ) {
52
- return new ObjectID ( Buffer . from ( id , 'hex' ) ) ;
52
+ return new ObjectID ( new Buffer ( id , 'hex' ) ) ;
53
53
} else if ( valid && typeof id == 'string' && id . length == 24 ) {
54
54
return ObjectID . createFromHexString ( id ) ;
55
55
} else if ( id != null && id . length === 12 ) {
@@ -290,7 +290,7 @@ ObjectID.createFromHexString = function createFromHexString (string) {
290
290
}
291
291
292
292
// Use Buffer.from method if available
293
- if ( hasBufferType ) return new ObjectID ( Buffer . from ( string , 'hex' ) ) ;
293
+ if ( hasBufferType ) return new ObjectID ( new Buffer ( string , 'hex' ) ) ;
294
294
295
295
// Calculate lengths
296
296
var array = new _Buffer ( 12 ) ;
Original file line number Diff line number Diff line change @@ -44,12 +44,12 @@ exports['should correctly create ObjectId from uppercase hexstring'] = function(
44
44
exports [ 'should correctly create ObjectId from Buffer' ] = function ( test ) {
45
45
if ( ! Buffer . from ) return test . done ( ) ;
46
46
var a = 'AAAAAAAAAAAAAAAAAAAAAAAA' ;
47
- var b = new ObjectId ( Buffer . from ( a , 'hex' ) ) ;
47
+ var b = new ObjectId ( new Buffer ( a , 'hex' ) ) ;
48
48
var c = b . equals ( a ) ; // => false
49
49
test . equal ( true , c ) ;
50
50
51
51
var a = 'aaaaaaaaaaaaaaaaaaaaaaaa' ;
52
- var b = new ObjectId ( Buffer . from ( a , 'hex' ) ) ;
52
+ var b = new ObjectId ( new Buffer ( a , 'hex' ) ) ;
53
53
var c = b . equals ( a ) ; // => true
54
54
test . equal ( a , b . toString ( ) ) ;
55
55
test . equal ( true , c ) ;
You can’t perform that action at this time.
0 commit comments