From fe7d6824c91b0c2b45c1248fc58847250f6c9f42 Mon Sep 17 00:00:00 2001 From: Peter Evers Date: Fri, 29 May 2020 08:27:57 +0200 Subject: [PATCH] fix DenoBlob name (#5879) --- cli/js/web/blob.ts | 10 +++++++++- cli/tests/unit/blob_test.ts | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cli/js/web/blob.ts b/cli/js/web/blob.ts index 546ea7e820..899c671358 100644 --- a/cli/js/web/blob.ts +++ b/cli/js/web/blob.ts @@ -161,7 +161,7 @@ async function readBytes( // Ensures it does not impact garbage collection. export const blobBytesWeakMap = new WeakMap(); -export class DenoBlob implements Blob { +class DenoBlob implements Blob { [bytesSymbol]: Uint8Array; readonly size: number = 0; readonly type: string = ""; @@ -216,3 +216,11 @@ export class DenoBlob implements Blob { return readBytes(getStream(this[bytesSymbol]).getReader()); } } + +// we want the Base class name to be the name of the class. +Object.defineProperty(DenoBlob, "name", { + value: "Blob", + configurable: true, +}); + +export { DenoBlob }; diff --git a/cli/tests/unit/blob_test.ts b/cli/tests/unit/blob_test.ts index 70f8fb3d5a..79e6f1f8f0 100644 --- a/cli/tests/unit/blob_test.ts +++ b/cli/tests/unit/blob_test.ts @@ -90,3 +90,8 @@ unitTest(async function blobStream(): Promise { await read(); assertEquals(decode(bytes), "Hello World"); }); + +unitTest(function blobConstructorNameIsBlob(): void { + const blob = new Blob(); + assertEquals(blob.constructor.name, "Blob"); +});