1+ import { satisfies } from 'semver' ;
12import { bson as BSON } from './bson-export' ;
23import type { InspectOptionsStylized , CustomInspectFunction } from 'util' ;
34import { inspect as utilInspect } from 'util' ;
@@ -26,11 +27,11 @@ function makeClasslessInspect<K extends BSONClassKey>(
2627) : CustomInspectFunction {
2728 const originalInspect = BSON [ className ] . prototype . inspect ;
2829 return function (
29- this : typeof originalInspect ,
30+ this : ( typeof BSON ) [ typeof className ] [ 'prototype' ] ,
3031 ...args : Parameters < typeof originalInspect >
3132 ) {
3233 return removeNewFromInspectResult ( originalInspect . apply ( this , args ) ) ;
33- } as CustomInspectFunction ;
34+ } satisfies CustomInspectFunction ;
3435}
3536
3637const binaryInspect = makeClasslessInspect ( 'Binary' ) ;
@@ -49,7 +50,7 @@ const binaryVectorInspect = function (
4950 // These arrays can be very large, so would prefer to use the default options instead.
5051 maxArrayLength : utilInspect . defaultOptions . maxArrayLength ,
5152 } )
52- ) } )`;
53+ ) } )) `;
5354 case BSON . Binary . VECTOR_TYPE . Float32 :
5455 return `Binary.fromFloat32Array(new Float32Array(${ removeTypedArrayPrefixFromInspectResult (
5556 utilInspect ( this . toFloat32Array ( ) , {
@@ -58,16 +59,16 @@ const binaryVectorInspect = function (
5859 // These arrays can be very large, so would prefer to use the default options instead.
5960 maxArrayLength : utilInspect . defaultOptions . maxArrayLength ,
6061 } )
61- ) } )`;
62+ ) } )) `;
6263 case BSON . Binary . VECTOR_TYPE . PackedBit :
63- return `Binary.fromPackedBitArray (new Uint8Array(${ removeTypedArrayPrefixFromInspectResult (
64+ return `Binary.fromPackedBits (new Uint8Array(${ removeTypedArrayPrefixFromInspectResult (
6465 utilInspect ( this . toPackedBits ( ) , {
6566 depth,
6667 ...options ,
6768 // These arrays can be very large, so would prefer to use the default options instead.
6869 maxArrayLength : utilInspect . defaultOptions . maxArrayLength ,
6970 } )
70- ) } )`;
71+ ) } )) `;
7172 default :
7273 return binaryInspect . call ( this , depth , options ) ;
7374 }
0 commit comments