mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 04:39:10 +00:00
Implement Blob url support for worker (#2729)
This commit is contained in:
parent
11c850af42
commit
ccee2f01ba
8 changed files with 118 additions and 24 deletions
|
@ -118,6 +118,10 @@ function processBlobParts(
|
|||
return bytes;
|
||||
}
|
||||
|
||||
// A WeakMap holding blob to byte array mapping.
|
||||
// Ensures it does not impact garbage collection.
|
||||
export const blobBytesWeakMap = new WeakMap<domTypes.Blob, Uint8Array>();
|
||||
|
||||
export class DenoBlob implements domTypes.Blob {
|
||||
private readonly [bytesSymbol]: Uint8Array;
|
||||
readonly size: number = 0;
|
||||
|
@ -161,6 +165,9 @@ export class DenoBlob implements domTypes.Blob {
|
|||
this[bytesSymbol] = bytes;
|
||||
this.size = bytes.byteLength;
|
||||
this.type = type;
|
||||
|
||||
// Register bytes for internal private use.
|
||||
blobBytesWeakMap.set(this, bytes);
|
||||
}
|
||||
|
||||
slice(start?: number, end?: number, contentType?: string): DenoBlob {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue