blob
Source: quickjs-blob.c — module export: Blob
A WHATWG-style Blob: an immutable chunk of binary data with a MIME type.
Constructor
new Blob(parts[, options]) // length 1parts is an array of strings / ArrayBuffers / typed arrays / other Blobs that are concatenated; options may carry a type (MIME) string.
Methods
| Method | Args | Description |
|---|---|---|
arrayBuffer() | 0 | Returns a promise resolving to the blob's contents as an ArrayBuffer. |
bytes() | 0 | Returns the blob's contents as a Uint8Array. |
text() | 0 | Returns a promise resolving to the contents decoded as a UTF-8 string. |
json() | 0 | Returns a promise resolving to the contents parsed as JSON (Bun's Blob.json()). A leading UTF-8 BOM is dropped and invalid UTF-8 becomes U+FFFD, as in text(). Rejects with SyntaxError for what JSON.parse rejects (empty, trailing data, comments, NaN); type is ignored. Parsed by the engine, so nesting deeper than the C stack rejects with SyntaxError ("stack overflow"), where Bun parses 100000 levels. |
stream() | 0 | Returns a ReadableStream over the blob's bytes. |
slice(start, end, contentType) | 0 | Returns a new Blob covering the byte range [start, end), optionally with a new MIME type. |
Properties (read-only)
| Property | Description |
|---|---|
size | Length of the blob in bytes (enumerable). |
type | MIME type string. |
[Symbol.toStringTag] | "Blob". |
Internal hook
Blob[Symbol.for('qjs.blob.fromArrayBuffer')](buffer) returns an untyped Blob over the bytes of buffer without copying them; the Blob holds a reference to buffer, which nobody may write from then on. fs.openAsBlob() uses it for a file mapping. Not a module export.
blob[Symbol.for('qjs.blob.segments')]() returns the Blob's bytes as one Uint8Array per segment, without copying; each view keeps the object owning its bytes alive and must not be written. Bun.write() hands them to fs.writevSync().
Export list
Generated by utilities/doc-api.js from the blob dump of utilities/api-surface.sh: 13 members. Edit the text above this block, not the block.
Functions: Blob[Symbol.for('qjs.blob.fromArrayBuffer')]()
Blob
class, constructible
- methods:
arrayBuffer(),bytes(),json(),slice(),stream(),text(),[Symbol.for('qjs.blob.segments')]() - properties:
size (get),type (get),[Symbol.toStringTag]