diff options
author | 2023-01-27 22:55:46 -0800 | |
---|---|---|
committer | 2023-01-27 22:55:46 -0800 | |
commit | aff91436c0998b0368f0970fa0da42afa09640fc (patch) | |
tree | 5b906088b4143c4c4963454246181fb1bf0728d5 /src/bun.js/builtins/cpp/JSBufferConstructorBuiltins.cpp | |
parent | 80751586390cd0c73fab9b5ff2e9d48b7df54719 (diff) | |
download | bun-aff91436c0998b0368f0970fa0da42afa09640fc.tar.gz bun-aff91436c0998b0368f0970fa0da42afa09640fc.tar.zst bun-aff91436c0998b0368f0970fa0da42afa09640fc.zip |
`Buffer.from` doesn't need to be the Buffer constructor
Diffstat (limited to 'src/bun.js/builtins/cpp/JSBufferConstructorBuiltins.cpp')
-rw-r--r-- | src/bun.js/builtins/cpp/JSBufferConstructorBuiltins.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/bun.js/builtins/cpp/JSBufferConstructorBuiltins.cpp b/src/bun.js/builtins/cpp/JSBufferConstructorBuiltins.cpp index a38be91a7..958126784 100644 --- a/src/bun.js/builtins/cpp/JSBufferConstructorBuiltins.cpp +++ b/src/bun.js/builtins/cpp/JSBufferConstructorBuiltins.cpp @@ -51,15 +51,12 @@ namespace WebCore { const JSC::ConstructAbility s_jsBufferConstructorFromCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_jsBufferConstructorFromCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_jsBufferConstructorFromCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferConstructorFromCodeLength = 1843; +const int s_jsBufferConstructorFromCodeLength = 1762; static const JSC::Intrinsic s_jsBufferConstructorFromCodeIntrinsic = JSC::NoIntrinsic; const char* const s_jsBufferConstructorFromCode = "(function (items) {\n" \ " \"use strict\";\n" \ "\n" \ - " if (!@isConstructor(this))\n" \ - " @throwTypeError(\"Buffer.from requires |this| to be a constructor\");\n" \ - "\n" \ " if (@isUndefinedOrNull(items)) {\n" \ " @throwTypeError(\n" \ " \"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\",\n" \ @@ -78,13 +75,13 @@ const char* const s_jsBufferConstructorFromCode = " ) {\n" \ " switch (@argumentCount()) {\n" \ " case 1: {\n" \ - " return new this(items);\n" \ + " return new @Buffer(items);\n" \ " }\n" \ " case 2: {\n" \ - " return new this(items, @argument(1));\n" \ + " return new @Buffer(items, @argument(1));\n" \ " }\n" \ " default: {\n" \ - " return new this(items, @argument(1), @argument(2));\n" \ + " return new @Buffer(items, @argument(1), @argument(2));\n" \ " }\n" \ " }\n" \ " }\n" \ @@ -103,13 +100,13 @@ const char* const s_jsBufferConstructorFromCode = " if (typeof primitive === \"string\") {\n" \ " switch (@argumentCount()) {\n" \ " case 1: {\n" \ - " return new this(primitive);\n" \ + " return new @Buffer(primitive);\n" \ " }\n" \ " case 2: {\n" \ - " return new this(primitive, @argument(1));\n" \ + " return new @Buffer(primitive, @argument(1));\n" \ " }\n" \ " default: {\n" \ - " return new this(primitive, @argument(1), @argument(2));\n" \ + " return new @Buffer(primitive, @argument(1), @argument(2));\n" \ " }\n" \ " }\n" \ " }\n" \ @@ -125,7 +122,7 @@ const char* const s_jsBufferConstructorFromCode = " //\n" \ " //\n" \ " //\n" \ - " return new this(@Uint8Array.from(arrayLike).buffer);\n" \ + " return new @Buffer(@Uint8Array.from(arrayLike).buffer);\n" \ "})\n" \ ; |