@@ -59,22 +59,6 @@ export abstract class InstrumentationBase<T = any>
5959 }
6060 }
6161
62- private _isSupported ( name : string , version : string ) : boolean {
63- for ( const module of this . _modules ) {
64- if ( module . name === name ) {
65- if ( ! module . supportedVersions ) {
66- return true ;
67- }
68-
69- return module . supportedVersions . some ( supportedVersion => {
70- return semver . satisfies ( version , supportedVersion ) ;
71- } ) ;
72- }
73- }
74-
75- return false ;
76- }
77-
7862 private _onRequire < T > (
7963 module : InstrumentationModuleDefinition < T > ,
8064 exports : T ,
@@ -93,7 +77,10 @@ export abstract class InstrumentationBase<T = any>
9377 module . moduleVersion = version ;
9478 if ( module . name === name ) {
9579 // main module
96- if ( typeof version === 'string' && this . _isSupported ( name , version ) ) {
80+ if (
81+ typeof version === 'string' &&
82+ isSupported ( module . supportedVersions , version )
83+ ) {
9784 if ( typeof module . patch === 'function' ) {
9885 module . moduleExports = exports ;
9986 if ( this . _enabled ) {
@@ -105,12 +92,7 @@ export abstract class InstrumentationBase<T = any>
10592 // internal file
10693 const files = module . files ?? [ ] ;
10794 const file = files . find ( file => file . name === name ) ;
108- if (
109- file &&
110- file . supportedVersions . some ( supportedVersion =>
111- semver . satisfies ( version , supportedVersion )
112- )
113- ) {
95+ if ( file && isSupported ( file . supportedVersions , version ) ) {
11496 file . moduleExports = exports ;
11597 if ( this . _enabled ) {
11698 return file . patch ( exports , module . moduleVersion ) ;
@@ -179,3 +161,9 @@ export abstract class InstrumentationBase<T = any>
179161 }
180162 }
181163}
164+
165+ function isSupported ( supportedVersions : string [ ] , version : string ) : boolean {
166+ return supportedVersions . some ( supportedVersion => {
167+ return semver . satisfies ( version , supportedVersion ) ;
168+ } ) ;
169+ }
0 commit comments