diff options
Diffstat (limited to 'doc/api')
-rw-r--r-- | doc/api/buffer.md | 14 | ||||
-rw-r--r-- | doc/api/url.md | 47 |
2 files changed, 61 insertions, 0 deletions
diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 7106d5c6b36..f419be1181a 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -4952,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 diff --git a/doc/api/url.md b/doc/api/url.md index 725084523df..d4b212f515d 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -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: |