Skip to content

Commit

Permalink
fix DenoBlob name (denoland#5879)
Browse files Browse the repository at this point in the history
  • Loading branch information
pevers authored and bartlomieju committed Jun 5, 2020
1 parent afbb5ab commit 1ac3fa4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cli/js/web/blob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ async function readBytes(
// Ensures it does not impact garbage collection.
export const blobBytesWeakMap = new WeakMap<Blob, Uint8Array>();

export class DenoBlob implements Blob {
class DenoBlob implements Blob {
[bytesSymbol]: Uint8Array;
readonly size: number = 0;
readonly type: string = "";
Expand Down Expand Up @@ -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 };
5 changes: 5 additions & 0 deletions cli/tests/unit/blob_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,8 @@ unitTest(async function blobStream(): Promise<void> {
await read();
assertEquals(decode(bytes), "Hello World");
});

unitTest(function blobConstructorNameIsBlob(): void {
const blob = new Blob();
assertEquals(blob.constructor.name, "Blob");
});

0 comments on commit 1ac3fa4

Please sign in to comment.