File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { setPrototypeOf } from './polyfill' ;
2
+
1
3
/** An error emitted by Sentry SDKs and related utilities. */
2
4
export class SentryError extends Error {
3
5
/** Display name of this error instance. */
@@ -8,6 +10,6 @@ export class SentryError extends Error {
8
10
9
11
// tslint:disable:no-unsafe-any
10
12
this . name = new . target . prototype . constructor . name ;
11
- Object . setPrototypeOf ( this , new . target . prototype ) ;
13
+ setPrototypeOf ( this , new . target . prototype ) ;
12
14
}
13
15
}
Original file line number Diff line number Diff line change
1
+ export const setPrototypeOf =
2
+ Object . setPrototypeOf || ( { __proto__ : [ ] } instanceof Array ? setProtoOf : mixinProperties ) ;
3
+
4
+ /**
5
+ * setPrototypeOf polyfill using __proto__
6
+ */
7
+ function setProtoOf < TTarget extends object , TProto > ( obj : TTarget , proto : TProto ) : TTarget & TProto {
8
+ // @ts -ignore
9
+ obj . __proto__ = proto ;
10
+ return obj as TTarget & TProto ;
11
+ }
12
+
13
+ /**
14
+ * setPrototypeOf polyfill using mixin
15
+ */
16
+ function mixinProperties < TTarget extends object , TProto > ( obj : TTarget , proto : TProto ) : TTarget & TProto {
17
+ for ( const prop in proto ) {
18
+ if ( ! obj . hasOwnProperty ( prop ) ) {
19
+ // @ts -ignore
20
+ obj [ prop ] = proto [ prop ] ;
21
+ }
22
+ }
23
+
24
+ return obj as TTarget & TProto ;
25
+ }
You can’t perform that action at this time.
0 commit comments