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' ;
22import { DEBUG_BUILD } from './debug-build' ;
33import { WINDOW } from './types' ;
44
@@ -15,14 +15,6 @@ interface CacheableImplementations {
1515
1616const cachedImplementations : Partial < CacheableImplementations > = { } ;
1717
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-
2618/**
2719 * Get the native implementation of a browser function.
2820 *
@@ -43,7 +35,7 @@ export function getNativeImplementation<T extends keyof CacheableImplementations
4335 let impl = WINDOW [ name ] as CacheableImplementations [ T ] ;
4436
4537 // Fast path to avoid DOM I/O
46- if ( isNative ( impl ) ) {
38+ if ( isNativeFunction ( impl ) ) {
4739 return ( cachedImplementations [ name ] = impl . bind ( WINDOW ) as CacheableImplementations [ T ] ) ;
4840 }
4941
Original file line number Diff line number Diff line change @@ -76,12 +76,13 @@ export function supportsFetch(): boolean {
7676 return false ;
7777 }
7878}
79+
7980/**
80- * isNativeFetch checks if the given function is a native implementation of fetch()
81+ * isNative checks if the given function is a native implementation
8182 */
8283// 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 ( ) ) ;
8586}
8687
8788/**
@@ -101,7 +102,7 @@ export function supportsNativeFetch(): boolean {
101102
102103 // Fast path to avoid DOM I/O
103104 // eslint-disable-next-line @typescript-eslint/unbound-method
104- if ( isNativeFetch ( WINDOW . fetch ) ) {
105+ if ( isNativeFunction ( WINDOW . fetch ) ) {
105106 return true ;
106107 }
107108
@@ -117,7 +118,7 @@ export function supportsNativeFetch(): boolean {
117118 doc . head . appendChild ( sandbox ) ;
118119 if ( sandbox . contentWindow && sandbox . contentWindow . fetch ) {
119120 // eslint-disable-next-line @typescript-eslint/unbound-method
120- result = isNativeFetch ( sandbox . contentWindow . fetch ) ;
121+ result = isNativeFunction ( sandbox . contentWindow . fetch ) ;
121122 }
122123 doc . head . removeChild ( sandbox ) ;
123124 } catch ( err ) {
You can’t perform that action at this time.
0 commit comments