diff --git a/src/runtime/node/buffer/index.ts b/src/runtime/node/buffer/index.ts index 4631656..167ccae 100644 --- a/src/runtime/node/buffer/index.ts +++ b/src/runtime/node/buffer/index.ts @@ -22,8 +22,8 @@ export const transcode = notImplemented("buffer.transcode"); export const isUtf8 = notImplemented("buffer.isUtf8"); export const isAscii = notImplemented("buffer.isAscii"); -export const btoa = global.btoa; -export const atob = globalThis.atob; +export const btoa = globalThis.btoa.bind(globalThis); +export const atob = globalThis.atob.bind(globalThis); export const kStringMaxLength = 0; // TODO export const constants = { diff --git a/test/workerd/tests.mjs b/test/workerd/tests.mjs index 0933975..fdee1dc 100644 --- a/test/workerd/tests.mjs +++ b/test/workerd/tests.mjs @@ -40,8 +40,8 @@ export const unenv_polyfills_buffer = { const Buffer = buffer.Buffer; assert.strictEqual(typeof buffer.isAscii, "function"); assert.strictEqual(typeof buffer.isUtf8, "function"); - //assert.strictEqual(buffer.btoa("hello"), "aGVsbG8="); - //assert.strictEqual(buffer.atob("aGVsbG8="), "hello"); + assert.strictEqual(buffer.btoa("hello"), "aGVsbG8="); + assert.strictEqual(buffer.atob("aGVsbG8="), "hello"); assert.strictEqual(typeof buffer.transcode, "function"); assert.strictEqual(typeof buffer.File, "function"); assert.strictEqual(typeof buffer.Blob, "function");