22if ( typeof ( Timestamp ) != "undefined" ) {
33 const OriginalTimestamp = Timestamp ;
44
5- // Reference: https://github.com/10gen /mongo/blob/master /src/mongo/scripting/mozjs/timestamp.cpp:67-78
5+ // Reference: https://github.com/mongodb /mongo/blob/c4d21d3346572e28df2f174df4d87e7618df4a77 /src/mongo/scripting/mozjs/timestamp.cpp#L67-L78
66 function validateTimestampComponent ( component , name ) {
77 const MAX_UINT32 = 4294967295 ;
88
99 if ( typeof component !== 'number' ) {
10- throw new Error ( name + " must be a number" ) ;
10+ throw new TypeError ( ` ${ name } must be a number` ) ;
1111 }
1212
1313 const val = Math . floor ( component ) ;
1414 if ( val < 0 || val > MAX_UINT32 ) {
15- throw new Error (
16- name + " must be non-negative and not greater than " + MAX_UINT32 + " , got " + val
15+ throw new TypeError (
16+ ` ${ name } must be non-negative and not greater than ${ MAX_UINT32 } , got ${ val } `
1717 ) ;
1818 }
1919
@@ -28,14 +28,14 @@ if (typeof (Timestamp) != "undefined") {
2828 if ( arguments . length === 1 ) {
2929 const proto = Object . getPrototypeOf ( t ) ;
3030 if ( ( proto === null || proto === Object . prototype ) && ( 't' in t || 'i' in t ) ) {
31- var validatedT = validateTimestampComponent ( t . t || 0 , "Timestamp time (seconds)" ) ;
32- var validatedI = validateTimestampComponent ( t . i || 0 , "Timestamp increment" ) ;
31+ const validatedT = validateTimestampComponent ( t . t || 0 , "Timestamp time (seconds)" ) ;
32+ const validatedI = validateTimestampComponent ( t . i || 0 , "Timestamp increment" ) ;
3333 return new OriginalTimestamp ( { t : validatedT , i : validatedI } ) ;
3434 }
3535 return new OriginalTimestamp ( t ) ;
3636 }
3737
38- // Reference: https://github.com/10gen /mongo/blob/master /src/mongo/scripting/mozjs/timestamp.cpp:91-98
38+ // Reference: https://github.com/mongodb /mongo/blob/c4d21d3346572e28df2f174df4d87e7618df4a77 /src/mongo/scripting/mozjs/timestamp.cpp#L91-L98
3939 if ( arguments . length === 2 ) {
4040 const validatedT = validateTimestampComponent ( t , "Timestamp time (seconds)" ) ;
4141 const validatedI = validateTimestampComponent ( i , "Timestamp increment" ) ;
@@ -47,8 +47,7 @@ if (typeof (Timestamp) != "undefined") {
4747
4848 Timestamp . prototype = OriginalTimestamp . prototype ;
4949
50- var staticProps = Object . getOwnPropertyNames ( OriginalTimestamp ) ;
51- for ( var key of staticProps ) {
50+ for ( const key of Object . getOwnPropertyNames ( OriginalTimestamp ) ) {
5251 // Skip prototype, length, name(function internals)
5352 if ( key !== 'prototype' && key !== 'length' && key !== 'name' ) {
5453 Timestamp [ key ] = OriginalTimestamp [ key ] ;
0 commit comments