From 2b02f7eb99d9fd84a0be50dd01122ae7b2874c0d Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 11 Sep 2022 17:11:11 -0700 Subject: Fix bug with `Buffer.from([123], "utf8")` cc @worm-emoji --- src/bun.js/builtins/js/JSBufferConstructor.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/bun.js/builtins/js') diff --git a/src/bun.js/builtins/js/JSBufferConstructor.js b/src/bun.js/builtins/js/JSBufferConstructor.js index 9a3f0e1b7..bfb122034 100644 --- a/src/bun.js/builtins/js/JSBufferConstructor.js +++ b/src/bun.js/builtins/js/JSBufferConstructor.js @@ -61,5 +61,8 @@ function from(items) { return result; } - return @tailCallForwardArguments(@Uint8Array.from, this); + // Don't pass the second argument because Node's Buffer.from doesn't accept + // a function and Uint8Array.from requires it if it exists + // That means we cannot use @tailCallFowrardArguments here, sadly + return this.toBuffer(@Uint8Array.from(arrayLike)); } -- cgit v1.2.3