Skip to content

Commit c31a76e

Browse files
committed
fix the prototype chain in a cross-platform way
1 parent e78e783 commit c31a76e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Decoder.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,14 @@ export class DecodeError extends Error {
6464
constructor(message: string) {
6565
super(message);
6666

67+
// fix the prototype chain in a cross-platform way
68+
const proto = Object.create(DecodeError.prototype);
69+
Object.setPrototypeOf(this, proto);
70+
6771
Object.defineProperty(this, "name", {
6872
configurable: true,
6973
enumerable: false,
70-
value: this.constructor.name,
74+
value: DecodeError.name,
7175
});
7276
}
7377
}

0 commit comments

Comments
 (0)