Skip to content

Commit cea76db

Browse files
committed
buffer: expose Blob as a global
`Blob` is defined as a global in the spec. We have WPT's for it, and it's graduated experimental. Time to expose it as a global. Signed-off-by: James M Snell <[email protected]> PR-URL: #41270 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Robert Nagy <[email protected]>
1 parent 99c18f4 commit cea76db

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ module.exports = {
363363
BigInt: 'readable',
364364
BigInt64Array: 'readable',
365365
BigUint64Array: 'readable',
366+
Blob: 'readable',
366367
DOMException: 'readable',
367368
Event: 'readable',
368369
EventTarget: 'readable',

doc/api/buffer.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ added:
458458
- v14.18.0
459459
changes:
460460
- version: REPLACEME
461-
pr-url: https://github.com/nodejs/node/pull/00000
461+
pr-url: https://github.com/nodejs/node/pull/41270
462462
description: No longer experimental.
463463
-->
464464

doc/api/globals.md

+10
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,16 @@ added: v17.3.0
199199

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

202+
## Class: `Blob`
203+
204+
<!-- YAML
205+
added: REPLACEME
206+
-->
207+
208+
<!-- type=global -->
209+
210+
See {Blob}.
211+
202212
## Class: `Buffer`
203213

204214
<!-- YAML

lib/.eslintrc.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ rules:
3737
# disabled with --no-harmony-atomics CLI flag.
3838
- name: Atomics
3939
message: "Use `const { Atomics } = globalThis;` instead of the global."
40+
- name: Blob
41+
message: "Use `const { Blob } = require('buffer');` instead of the global."
4042
- name: Buffer
4143
message: "Use `const { Buffer } = require('buffer');` instead of the global."
4244
- name: DOMException

lib/internal/bootstrap/node.js

+7
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ function setupGlobalProxy() {
444444

445445
function setupBuffer() {
446446
const {
447+
Blob,
447448
Buffer,
448449
atob,
449450
btoa,
@@ -456,6 +457,12 @@ function setupBuffer() {
456457
delete bufferBinding.zeroFill;
457458

458459
ObjectDefineProperties(globalThis, {
460+
'Blob': {
461+
value: Blob,
462+
enumerable: false,
463+
writable: true,
464+
configurable: true,
465+
},
459466
'Buffer': {
460467
value: Buffer,
461468
enumerable: false,

0 commit comments

Comments
 (0)