mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:47:44 +00:00
LibJS: Add an Iterator constructor and object
The Iterator object cannot be constructed directly but can be subclassed or created with `Iterator.from` (not implemented here).
This commit is contained in:
parent
428109e709
commit
5736b53013
9 changed files with 165 additions and 1 deletions
29
Userland/Libraries/LibJS/Runtime/IteratorConstructor.h
Normal file
29
Userland/Libraries/LibJS/Runtime/IteratorConstructor.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Runtime/NativeFunction.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
class IteratorConstructor : public NativeFunction {
|
||||
JS_OBJECT(IteratorConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
|
||||
|
||||
private:
|
||||
explicit IteratorConstructor(Realm&);
|
||||
|
||||
virtual bool has_constructor() const override { return true; }
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue