@@ -237,7 +237,7 @@ function logValue(
237
237
value , // : any,
238
238
operation , // : string, // from JSOperation object please
239
239
callContext , // : any,
240
- logSettings = false , // : LogSettings,
240
+ logSettings : typeof jsInstrumentationSettings [ 0 ] | { logFunctionsAsStrings : boolean } = { logFunctionsAsStrings : false } , // : LogSettings,
241
241
) {
242
242
if ( inLog ) {
243
243
return ;
@@ -327,7 +327,16 @@ function logCall(instrumentedFunctionName, args, callContext, _logSettings) {
327
327
/**
328
328
* Provides the properties per prototype object
329
329
*/
330
- Object . getPrototypeByDepth = function ( subject , depth ) {
330
+
331
+ declare global {
332
+ interface Object {
333
+ getPrototypeByDepth ( subject : string | undefined , depth : number ) : any
334
+ getPropertyNamesPerDepth ( subject : any , maxDepth : number ) : any
335
+ findPropertyInChain ( subject , propertyName )
336
+ }
337
+ }
338
+
339
+ Object . prototype . getPrototypeByDepth = function ( subject , depth ) {
331
340
if ( subject === undefined ) {
332
341
throw new Error ( "Can't get property names for undefined" ) ;
333
342
}
@@ -348,7 +357,7 @@ Object.getPrototypeByDepth = function (subject, depth) {
348
357
* Traverses the prototype chain to collect properties. Returns an array containing
349
358
* an object with the depth, propertyNames and scanned subject
350
359
*/
351
- Object . getPropertyNamesPerDepth = function ( subject , maxDepth = 0 ) {
360
+ Object . prototype . getPropertyNamesPerDepth = function ( subject , maxDepth = 0 ) {
352
361
if ( subject === undefined ) {
353
362
throw new Error ( "Can't get property names for undefined" ) ;
354
363
}
@@ -370,7 +379,7 @@ Object.getPropertyNamesPerDepth = function (subject, maxDepth = 0) {
370
379
/**
371
380
* Finds a property along the prototype chain
372
381
*/
373
- Object . findPropertyInChain = function ( subject , propertyName ) {
382
+ Object . prototype . findPropertyInChain = function ( subject , propertyName ) {
374
383
if ( subject === undefined || propertyName === undefined ) {
375
384
throw new Error ( "Object and property name must be defined" ) ;
376
385
}
@@ -457,9 +466,9 @@ function notify(type, content) {
457
466
} ) ;
458
467
}
459
468
460
- function filterPropertiesPerDepth ( collection , excluded ) {
461
- for ( let i = 0 ; i < collection . length ; i ++ ) {
462
- collection [ i ] . propertyNames = collection [ i ] . propertyNames . filter (
469
+ function filterPropertiesPerDepth < T > ( collection : { propertyNames : T [ ] } [ ] , excluded : T [ ] ) {
470
+ for ( const elem of collection ) {
471
+ elem . propertyNames = elem . propertyNames . filter (
463
472
( p ) => ! excluded . includes ( p ) ,
464
473
) ;
465
474
}
0 commit comments