Bun

class

buffer.Blob

class Blob

A Blob encapsulates immutable, raw data that can be safely shared across multiple worker threads.

  • readonly size: number

    The total size of the Blob in bytes.

  • readonly type: string

    The content-type of the Blob.

  • Returns a promise that fulfills with an ArrayBuffer containing a copy of the Blob data.

  • bytes(): Promise<Uint8Array<ArrayBufferLike>>;

    The blob.bytes() method returns the byte of the Blob object as a Promise<Uint8Array>.

    const blob = new Blob(['hello']);
    blob.bytes().then((bytes) => {
      console.log(bytes); // Outputs: Uint8Array(5) [ 104, 101, 108, 108, 111 ]
    });
    
  • start?: number,
    end?: number,
    type?: string
    ): Blob;

    Creates and returns a new Blob containing a subset of this Blob objects data. The original Blob is not altered.

    @param start

    The starting index.

    @param end

    The ending index.

    @param type

    The content-type for the new Blob

  • Returns a new ReadableStream that allows the content of the Blob to be read.

  • text(): Promise<string>;

    Returns a promise that fulfills with the contents of the Blob decoded as a UTF-8 string.