From aa0ba6580eeb8045433d3eeffc19fc14a36f0361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 21 Nov 2024 16:27:37 +0000 Subject: [PATCH] fix: Buffer global in --unstable-node-globals (#26973) --- runtime/js/98_global_scope_shared.js | 2 +- tests/specs/run/unstable/node_globals.out | 8 +++++++- tests/specs/run/unstable/node_globals.ts | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/runtime/js/98_global_scope_shared.js b/runtime/js/98_global_scope_shared.js index f8e76b7ce7..c01bde6fad 100644 --- a/runtime/js/98_global_scope_shared.js +++ b/runtime/js/98_global_scope_shared.js @@ -32,7 +32,7 @@ import { DOMException } from "ext:deno_web/01_dom_exception.js"; import * as abortSignal from "ext:deno_web/03_abort_signal.js"; import * as imageData from "ext:deno_web/16_image_data.js"; import process from "node:process"; -import Buffer from "node:buffer"; +import { Buffer } from "node:buffer"; import { clearImmediate, setImmediate } from "node:timers"; import { loadWebGPU } from "ext:deno_webgpu/00_init.js"; import * as webgpuSurface from "ext:deno_webgpu/02_surface.js"; diff --git a/tests/specs/run/unstable/node_globals.out b/tests/specs/run/unstable/node_globals.out index 77045c7cbd..8262ace271 100644 --- a/tests/specs/run/unstable/node_globals.out +++ b/tests/specs/run/unstable/node_globals.out @@ -1,4 +1,10 @@ global: true -Buffer: true +Buffer: function from( + value, + encodingOrOffset, + length, +) { + return _from(value, encodingOrOffset, length); +} setImmediate: true clearImmediate: true diff --git a/tests/specs/run/unstable/node_globals.ts b/tests/specs/run/unstable/node_globals.ts index 706b7eb654..3a000ea341 100644 --- a/tests/specs/run/unstable/node_globals.ts +++ b/tests/specs/run/unstable/node_globals.ts @@ -2,6 +2,6 @@ import * as nodeBuffer from "node:buffer"; import * as nodeTimers from "node:timers"; console.log(`global: ${globalThis === global}`); -console.log(`Buffer: ${Buffer === nodeBuffer.default}`); +console.log(`Buffer: ${Buffer.from}`); console.log(`setImmediate: ${setImmediate === nodeTimers.setImmediate}`); console.log(`clearImmediate: ${clearImmediate === nodeTimers.clearImmediate}`);