|
@@ -55,33 +55,6 @@ Value TypedArrayConstructor::construct(FunctionObject&)
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
-// 23.2.4.2 TypedArrayCreate ( constructor, argumentList ), https://tc39.es/ecma262/#typedarray-create
|
|
|
-static TypedArrayBase* typed_array_create(GlobalObject& global_object, FunctionObject& constructor, MarkedValueList arguments)
|
|
|
-{
|
|
|
- auto& vm = global_object.vm();
|
|
|
-
|
|
|
- auto argument_count = arguments.size();
|
|
|
- auto first_argument = argument_count > 0 ? arguments[0] : js_undefined();
|
|
|
-
|
|
|
- auto new_typed_array = vm.construct(constructor, constructor, move(arguments));
|
|
|
- if (vm.exception())
|
|
|
- return nullptr;
|
|
|
- if (!new_typed_array.is_object() || !new_typed_array.as_object().is_typed_array()) {
|
|
|
- vm.throw_exception<TypeError>(global_object, ErrorType::NotA, "TypedArray");
|
|
|
- return nullptr;
|
|
|
- }
|
|
|
- auto& typed_array = static_cast<TypedArrayBase&>(new_typed_array.as_object());
|
|
|
- if (typed_array.viewed_array_buffer()->is_detached()) {
|
|
|
- vm.throw_exception<TypeError>(global_object, ErrorType::DetachedArrayBuffer);
|
|
|
- return nullptr;
|
|
|
- }
|
|
|
- if (argument_count == 1 && first_argument.is_number() && typed_array.array_length() < first_argument.as_double()) {
|
|
|
- vm.throw_exception<TypeError>(global_object, ErrorType::InvalidLength, "typed array");
|
|
|
- return nullptr;
|
|
|
- }
|
|
|
- return &typed_array;
|
|
|
-}
|
|
|
-
|
|
|
// 23.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ), https://tc39.es/ecma262/#sec-%typedarray%.from
|
|
|
JS_DEFINE_NATIVE_FUNCTION(TypedArrayConstructor::from)
|
|
|
{
|