From bf69e61a9e9ec6d783977a73eab350e0730d7d4b Mon Sep 17 00:00:00 2001 From: Soney Mathew Date: Sat, 23 Jul 2022 20:52:23 +1000 Subject: [PATCH 1/2] [Bun.js] support for util.TextEncoder --- src/node-fallbacks/util.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/node-fallbacks/util.js b/src/node-fallbacks/util.js index 4b20b6354c2f..19ccac1d92c5 100644 --- a/src/node-fallbacks/util.js +++ b/src/node-fallbacks/util.js @@ -1 +1,5 @@ export * from "util"; + +const TextEncoder = globalThis.TextEncoder; + +export { TextEncoder }; From b98007bf7e8fdad63e8a8a16cc0f3aabff02b0cd Mon Sep 17 00:00:00 2001 From: Soney Mathew Date: Sun, 24 Jul 2022 08:45:38 +1000 Subject: [PATCH 2/2] [Bun.js] test for util.TextEncoder --- test/bun.js/util.test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 test/bun.js/util.test.js diff --git a/test/bun.js/util.test.js b/test/bun.js/util.test.js new file mode 100644 index 000000000000..1e4a48751895 --- /dev/null +++ b/test/bun.js/util.test.js @@ -0,0 +1,13 @@ +import { expect, describe, it } from "bun:test"; +import { TextEncoder } from "util"; + + +describe("util", () => { + describe("TextEncoder", () => { + // test/bun.js/text-encoder.test.js covers test cases for TextEncoder + // here we test only if we use the same via util.TextEncoder + it("is same as global TextEncoder", () => { + expect(TextEncoder === globalThis.TextEncoder).toBe(true); + }); + }); +});