From 5833ec1226d783656a47b004266313c964886fe3 Mon Sep 17 00:00:00 2001 From: George Fu Date: Fri, 20 Sep 2024 16:57:36 +0000 Subject: [PATCH] use class inheritance --- .../src/checksum/createChecksumStream.browser.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/util-stream/src/checksum/createChecksumStream.browser.ts b/packages/util-stream/src/checksum/createChecksumStream.browser.ts index 7dc69867552..d354ec16c70 100644 --- a/packages/util-stream/src/checksum/createChecksumStream.browser.ts +++ b/packages/util-stream/src/checksum/createChecksumStream.browser.ts @@ -107,6 +107,8 @@ export const createChecksumStream = ({ return readable; }; +const ReadableStreamRef = typeof ReadableStream === "function" ? ReadableStream : function (): void {}; + /** * This stub exists so that the readable returned by createChecksumStream * identifies as "ChecksumStream" in alignment with the Node.js @@ -114,9 +116,4 @@ export const createChecksumStream = ({ * * @extends ReadableStream */ -export function ChecksumStream(): void {} - -if (typeof ReadableStream === "function") { - ChecksumStream.prototype = Object.create(ReadableStream.prototype); - ChecksumStream.prototype.constructor = ChecksumStream; -} +export class ChecksumStream extends (ReadableStreamRef as any) {}