Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -507,15 +507,24 @@ added: v15.7.0
Creates and returns a new `Blob` containing a subset of this `Blob` objects
data. The original `Blob` is not altered.

### `blob.stream()`
<!-- YAML
added: REPLACEME
-->

* Returns: {ReadableStream}

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

### `blob.text()`
<!-- YAML
added: v15.7.0
-->

* Returns: {Promise}

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

### `blob.type`
<!-- YAML
Expand Down Expand Up @@ -4943,6 +4952,20 @@ added: v3.0.0

An alias for [`buffer.constants.MAX_STRING_LENGTH`][].

### `buffer.resolveObjectURL(id)`
<!-- YAML
added: REPLACEME
-->

> Stability: 1 - Experimental

* `id` {string} A `'blob:nodedata:...` URL string returned by a prior call to
`URL.createObjectURL()`.
* Returns: {Blob}

Resolves a `'blob:nodedata:...'` an associated {Blob} object registered using
a prior call to `URL.createObjectURL()`.

### `buffer.transcode(source, fromEnc, toEnc)`
<!-- YAML
added: v7.1.0
Expand Down
47 changes: 47 additions & 0 deletions doc/api/url.md
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,53 @@ console.log(JSON.stringify(myURLs));
// Prints ["https://www.example.com/","https://test.example.org/"]
```

#### `URL.createObjectURL(blob)`
<!-- YAML
added: REPLACEME
-->

> Stability: 1 - Experimental

* `blob` {Blob}
* Returns: {string}

Creates a `'blob:nodedata:...'` URL string that represents the given {Blob}
object and can be used to retrieve the `Blob` later.

```js
const {
Blob,
resolveObjectURL,
} = require('buffer');

const blob = new Blob(['hello']);
const id = URL.createObjectURL(blob);

// later...

const otherBlob = resolveObjectURL(id);
console.log(otherBlob.size);
```

The data stored by the registered {Blob} will be retained in memory until
`URL.revokeObjectURL()` is called to remove it.

`Blob` objects are registered within the current thread. If using Worker
Threads, `Blob` objects registered within one Worker will not be available
to other workers or the main thread.

#### `URL.revokeObjectURL(id)`
<!-- YAML
added: REPLACEME
-->

> Stability: 1 - Experimental

* `id` {string} A `'blob:nodedata:...` URL string returned by a prior call to
`URL.createObjectURL()`.

Removes the stored {Blob} identified by the given ID.

### Class: `URLSearchParams`
<!-- YAML
added:
Expand Down
2 changes: 2 additions & 0 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const {

const {
Blob,
resolveObjectURL,
} = require('internal/blob');

FastBuffer.prototype.constructor = Buffer;
Expand Down Expand Up @@ -1239,6 +1240,7 @@ function atob(input) {

module.exports = {
Blob,
resolveObjectURL,
Buffer,
SlowBuffer,
transcode,
Expand Down
Loading