Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buffer: graduate Blob from experimental and expose as global #41270

Closed
wants to merge 3 commits into from
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ module.exports = {
BigInt: 'readable',
BigInt64Array: 'readable',
BigUint64Array: 'readable',
Blob: 'readable',
DOMException: 'readable',
Event: 'readable',
EventTarget: 'readable',
Expand Down
6 changes: 4 additions & 2 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,12 @@ Additionally, the [`buf.values()`][], [`buf.keys()`][], and
added:
- v15.7.0
- v14.18.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/41270
description: No longer experimental.
-->

> Stability: 1 - Experimental

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

Expand Down
10 changes: 10 additions & 0 deletions doc/api/globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@ added: v17.3.0

If `abortSignal.aborted` is `true`, throws `abortSignal.reason`.

## Class: `Blob`

<!-- YAML
added: REPLACEME
-->

<!-- type=global -->

See {Blob}.

## Class: `Buffer`

<!-- YAML
Expand Down
2 changes: 2 additions & 0 deletions lib/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ rules:
# disabled with --no-harmony-atomics CLI flag.
- name: Atomics
message: "Use `const { Atomics } = globalThis;` instead of the global."
- name: Blob
message: "Use `const { Blob } = require('buffer');` instead of the global."
- name: Buffer
message: "Use `const { Buffer } = require('buffer');` instead of the global."
- name: DOMException
Expand Down
2 changes: 0 additions & 2 deletions lib/internal/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const {
const {
createDeferredPromise,
customInspectSymbol: kInspect,
emitExperimentalWarning,
} = require('internal/util');
const { inspect } = require('internal/util/inspect');

Expand Down Expand Up @@ -134,7 +133,6 @@ class Blob {
* @constructs {Blob}
*/
constructor(sources = [], options = {}) {
emitExperimentalWarning('buffer.Blob');
if (sources === null ||
typeof sources[SymbolIterator] !== 'function' ||
typeof sources === 'string') {
Expand Down
7 changes: 7 additions & 0 deletions lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ function setupGlobalProxy() {

function setupBuffer() {
const {
Blob,
Buffer,
atob,
btoa,
Expand All @@ -456,6 +457,12 @@ function setupBuffer() {
delete bufferBinding.zeroFill;

ObjectDefineProperties(globalThis, {
'Blob': {
value: Blob,
enumerable: false,
writable: true,
configurable: true,
},
'Buffer': {
value: Buffer,
enumerable: false,
Expand Down