| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 41955e5 commit f7c4015
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,6 +65,13 @@ defineOperation(globalThis, 'clearTimeout', timers.clearTimeout); | |||
| 65 | 65 | defineOperation(globalThis, 'setInterval', timers.setInterval); | |
| 66 | 66 | defineOperation(globalThis, 'setTimeout', timers.setTimeout); | |
| 67 | 67 | ||
| 68 | + const buffer = require('buffer'); | ||
| 69 | + defineOperation(globalThis, 'atob', buffer.atob); | ||
| 70 | + defineOperation(globalThis, 'btoa', buffer.btoa); | ||
| 71 | + | ||
| 72 | + // https://www.w3.org/TR/FileAPI/#dfn-Blob | ||
| 73 | + exposeInterface(globalThis, 'Blob', buffer.Blob); | ||
| 74 | + | ||
| 68 | 75 | // https://www.w3.org/TR/hr-time-2/#the-performance-attribute | |
| 69 | 76 | defineReplacableAttribute(globalThis, 'performance', | |
| 70 | 77 | require('perf_hooks').performance); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,7 +45,6 @@ const { | |||
| 45 | 45 | FunctionPrototypeCall, | |
| 46 | 46 | JSONParse, | |
| 47 | 47 | ObjectDefineProperty, | |
| 48 | - ObjectDefineProperties, | ||
| 49 | 48 | ObjectGetPrototypeOf, | |
| 50 | 49 | ObjectPreventExtensions, | |
| 51 | 50 | ObjectSetPrototypeOf, | |
@@ -377,13 +376,21 @@ function setupProcessObject() { | |||
| 377 | 376 | configurable: false, | |
| 378 | 377 | value: 'process' | |
| 379 | 378 | }); | |
| 380 | - // Make process globally available to users by putting it on the global proxy | ||
| 379 | + | ||
| 380 | + // Create global.process as getters so that we have a | ||
| 381 | + // deprecation path for these in ES Modules. | ||
| 382 | + // See https://github.com/nodejs/node/pull/26334. | ||
| 383 | + let _process = process; | ||
| 381 | 384 | ObjectDefineProperty(globalThis, 'process', { | |
| 382 | 385 | __proto__: null, | |
| 383 | - value: process, | ||
| 386 | + get() { | ||
| 387 | + return _process; | ||
| 388 | + }, | ||
| 389 | + set(value) { | ||
| 390 | + _process = value; | ||
| 391 | + }, | ||
| 384 | 392 | enumerable: false, | |
| 385 | - writable: true, | ||
| 386 | - configurable: true | ||
| 393 | + configurable: true, | ||
| 387 | 394 | }); | |
| 388 | 395 | } | |
| 389 | 396 | ||
@@ -399,10 +406,7 @@ function setupGlobalProxy() { | |||
| 399 | 406 | ||
| 400 | 407 | function setupBuffer() { | |
| 401 | 408 | const { | |
| 402 | - Blob, | ||
| 403 | 409 | Buffer, | |
| 404 | - atob, | ||
| 405 | - btoa, | ||
| 406 | 410 | } = require('buffer'); | |
| 407 | 411 | const bufferBinding = internalBinding('buffer'); | |
| 408 | 412 | ||
@@ -411,34 +415,19 @@ function setupBuffer() { | |||
| 411 | 415 | delete bufferBinding.setBufferPrototype; | |
| 412 | 416 | delete bufferBinding.zeroFill; | |
| 413 | 417 | ||
| 414 | - ObjectDefineProperties(globalThis, { | ||
| 415 | - 'Blob': { | ||
| 416 | - __proto__: null, | ||
| 417 | - value: Blob, | ||
| 418 | - enumerable: false, | ||
| 419 | - writable: true, | ||
| 420 | - configurable: true, | ||
| 421 | - }, | ||
| 422 | - 'Buffer': { | ||
| 423 | - __proto__: null, | ||
| 424 | - value: Buffer, | ||
| 425 | - enumerable: false, | ||
| 426 | - writable: true, | ||
| 427 | - configurable: true, | ||
| 428 | - }, | ||
| 429 | - 'atob': { | ||
| 430 | - __proto__: null, | ||
| 431 | - value: atob, | ||
| 432 | - enumerable: false, | ||
| 433 | - writable: true, | ||
| 434 | - configurable: true, | ||
| 418 | + // Create global.Buffer as getters so that we have a | ||
| 419 | + // deprecation path for these in ES Modules. | ||
| 420 | + // See https://github.com/nodejs/node/pull/26334. | ||
| 421 | + let _Buffer = Buffer; | ||
| 422 | + ObjectDefineProperty(globalThis, 'Buffer', { | ||
| 423 | + __proto__: null, | ||
| 424 | + get() { | ||
| 425 | + return _Buffer; | ||
| 435 | 426 | }, | |
| 436 | - 'btoa': { | ||
| 437 | - __proto__: null, | ||
| 438 | - value: btoa, | ||
| 439 | - enumerable: false, | ||
| 440 | - writable: true, | ||
| 441 | - configurable: true, | ||
| 427 | + set(value) { | ||
| 428 | + _Buffer = value; | ||
| 442 | 429 | }, | |
| 430 | + enumerable: false, | ||
| 431 | + configurable: true, | ||
| 443 | 432 | }); | |
| 444 | 433 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,6 @@ const { | |||
| 23 | 23 | exposeInterface, | |
| 24 | 24 | } = require('internal/util'); | |
| 25 | 25 | ||
| 26 | - const { Buffer } = require('buffer'); | ||
| 27 | 26 | const { | |
| 28 | 27 | ERR_MANIFEST_ASSERT_INTEGRITY, | |
| 29 | 28 | } = require('internal/errors').codes; | |
@@ -408,35 +407,6 @@ function initializeDeprecations() { | |||
| 408 | 407 | 'process._tickCallback() is deprecated', | |
| 409 | 408 | 'DEP0134'); | |
| 410 | 409 | } | |
| 411 | - | ||
| 412 | - // Create global.process and global.Buffer as getters so that we have a | ||
| 413 | - // deprecation path for these in ES Modules. | ||
| 414 | - // See https://github.com/nodejs/node/pull/26334. | ||
| 415 | - let _process = process; | ||
| 416 | - ObjectDefineProperty(globalThis, 'process', { | ||
| 417 | - __proto__: null, | ||
| 418 | - get() { | ||
| 419 | - return _process; | ||
| 420 | - }, | ||
| 421 | - set(value) { | ||
| 422 | - _process = value; | ||
| 423 | - }, | ||
| 424 | - enumerable: false, | ||
| 425 | - configurable: true | ||
| 426 | - }); | ||
| 427 | - | ||
| 428 | - let _Buffer = Buffer; | ||
| 429 | - ObjectDefineProperty(globalThis, 'Buffer', { | ||
| 430 | - __proto__: null, | ||
| 431 | - get() { | ||
| 432 | - return _Buffer; | ||
| 433 | - }, | ||
| 434 | - set(value) { | ||
| 435 | - _Buffer = value; | ||
| 436 | - }, | ||
| 437 | - enumerable: false, | ||
| 438 | - configurable: true | ||
| 439 | - }); | ||
| 440 | 410 | } | |
| 441 | 411 | ||
| 442 | 412 | function setupChildProcessIpcChannel() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,6 +49,8 @@ builtinModules.forEach((moduleName) => { | |||
| 49 | 49 | 'clearImmediate', | |
| 50 | 50 | 'clearInterval', | |
| 51 | 51 | 'clearTimeout', | |
| 52 | + 'atob', | ||
| 53 | + 'btoa', | ||
| 52 | 54 | 'performance', | |
| 53 | 55 | 'setImmediate', | |
| 54 | 56 | 'setInterval', | |
| Back | FazBrowse Home | New Git URL |
0 commit comments