mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:57:45 +00:00
LibJS: Add %TypedArray%.prototype.forEach
This commit is contained in:
parent
91af985718
commit
68f11a272b
3 changed files with 156 additions and 0 deletions
|
@ -29,6 +29,7 @@ void TypedArrayPrototype::initialize(GlobalObject& object)
|
|||
define_native_function(vm.names.every, every, 1, attr);
|
||||
define_native_function(vm.names.find, find, 1, attr);
|
||||
define_native_function(vm.names.findIndex, find_index, 1, attr);
|
||||
define_native_function(vm.names.forEach, for_each, 1, attr);
|
||||
}
|
||||
|
||||
TypedArrayPrototype::~TypedArrayPrototype()
|
||||
|
@ -169,6 +170,15 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::find_index)
|
|||
return Value(result_index);
|
||||
}
|
||||
|
||||
// 23.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.foreach
|
||||
JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::for_each)
|
||||
{
|
||||
for_each_item(vm, global_object, "forEach", [](auto, auto, auto) {
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
return js_undefined();
|
||||
}
|
||||
|
||||
// 23.2.3.1 get %TypedArray%.prototype.buffer, https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.buffer
|
||||
JS_DEFINE_NATIVE_GETTER(TypedArrayPrototype::buffer_getter)
|
||||
{
|
||||
|
|
|
@ -28,6 +28,7 @@ private:
|
|||
JS_DECLARE_NATIVE_FUNCTION(every);
|
||||
JS_DECLARE_NATIVE_FUNCTION(find);
|
||||
JS_DECLARE_NATIVE_FUNCTION(find_index);
|
||||
JS_DECLARE_NATIVE_FUNCTION(for_each);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue