File tree Expand file tree Collapse file tree 2 files changed +8
-15
lines changed Expand file tree Collapse file tree 2 files changed +8
-15
lines changed Original file line number Diff line number Diff line change 1
- import { logger } from '@sentry/utils' ;
1
+ import { isNativeFunction , logger } from '@sentry/utils' ;
2
2
import { DEBUG_BUILD } from './debug-build' ;
3
3
import { WINDOW } from './types' ;
4
4
@@ -15,14 +15,6 @@ interface CacheableImplementations {
15
15
16
16
const cachedImplementations : Partial < CacheableImplementations > = { } ;
17
17
18
- /**
19
- * isNative checks if the given function is a native implementation
20
- */
21
- // eslint-disable-next-line @typescript-eslint/ban-types
22
- function isNative ( func : Function ) : boolean {
23
- return func && / ^ f u n c t i o n \s + \w + \( \) \s + \{ \s + \[ n a t i v e c o d e \] \s + \} $ / . test ( func . toString ( ) ) ;
24
- }
25
-
26
18
/**
27
19
* Get the native implementation of a browser function.
28
20
*
@@ -43,7 +35,7 @@ export function getNativeImplementation<T extends keyof CacheableImplementations
43
35
let impl = WINDOW [ name ] as CacheableImplementations [ T ] ;
44
36
45
37
// Fast path to avoid DOM I/O
46
- if ( isNative ( impl ) ) {
38
+ if ( isNativeFunction ( impl ) ) {
47
39
return ( cachedImplementations [ name ] = impl . bind ( WINDOW ) as CacheableImplementations [ T ] ) ;
48
40
}
49
41
Original file line number Diff line number Diff line change @@ -76,12 +76,13 @@ export function supportsFetch(): boolean {
76
76
return false ;
77
77
}
78
78
}
79
+
79
80
/**
80
- * isNativeFetch checks if the given function is a native implementation of fetch()
81
+ * isNative checks if the given function is a native implementation
81
82
*/
82
83
// eslint-disable-next-line @typescript-eslint/ban-types
83
- export function isNativeFetch ( func : Function ) : boolean {
84
- return func && / ^ f u n c t i o n f e t c h \( \) \s + \{ \s + \[ n a t i v e c o d e \] \s + \} $ / . test ( func . toString ( ) ) ;
84
+ export function isNativeFunction ( func : Function ) : boolean {
85
+ return func && / ^ f u n c t i o n \s + \w + \( \) \s + \{ \s + \[ n a t i v e c o d e \] \s + \} $ / . test ( func . toString ( ) ) ;
85
86
}
86
87
87
88
/**
@@ -101,7 +102,7 @@ export function supportsNativeFetch(): boolean {
101
102
102
103
// Fast path to avoid DOM I/O
103
104
// eslint-disable-next-line @typescript-eslint/unbound-method
104
- if ( isNativeFetch ( WINDOW . fetch ) ) {
105
+ if ( isNativeFunction ( WINDOW . fetch ) ) {
105
106
return true ;
106
107
}
107
108
@@ -117,7 +118,7 @@ export function supportsNativeFetch(): boolean {
117
118
doc . head . appendChild ( sandbox ) ;
118
119
if ( sandbox . contentWindow && sandbox . contentWindow . fetch ) {
119
120
// eslint-disable-next-line @typescript-eslint/unbound-method
120
- result = isNativeFetch ( sandbox . contentWindow . fetch ) ;
121
+ result = isNativeFunction ( sandbox . contentWindow . fetch ) ;
121
122
}
122
123
doc . head . removeChild ( sandbox ) ;
123
124
} catch ( err ) {
You can’t perform that action at this time.
0 commit comments