blob: dfe714a97a6ae2047cefaaee05cbf174bb2b2b4c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import { getOriginalFunction } from '@sentry/utils';
let originalFunctionToString;
/** Patch toString calls to return proper name for wrapped functions */
class FunctionToString {constructor() { FunctionToString.prototype.__init.call(this); }
/**
* @inheritDoc
*/
static __initStatic() {this.id = 'FunctionToString';}
/**
* @inheritDoc
*/
__init() {this.name = FunctionToString.id;}
/**
* @inheritDoc
*/
setupOnce() {
// eslint-disable-next-line @typescript-eslint/unbound-method
originalFunctionToString = Function.prototype.toString;
// intrinsics (like Function.prototype) might be immutable in some environments
// e.g. Node with --frozen-intrinsics, XS (an embedded JavaScript engine) or SES (a JavaScript proposal)
try {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Function.prototype.toString = function ( ...args) {
const context = getOriginalFunction(this) || this;
return originalFunctionToString.apply(context, args);
};
} catch (e) {
// ignore errors here, just don't patch this
}
}
} FunctionToString.__initStatic();
export { FunctionToString };
//# sourceMappingURL=functiontostring.js.map
|