mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:27:35 +00:00
LibJS: Integrate iterator protocol into language features
Finally use Symbol.iterator protocol in language features :) currently only used in for-of loops and spread expressions, but will have more uses later (Maps, Sets, Array.from, etc).
This commit is contained in:
parent
4970c448bf
commit
a51b2393f2
8 changed files with 187 additions and 127 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
||||
namespace JS {
|
||||
|
@ -33,13 +34,13 @@ namespace JS {
|
|||
// Common iterator operations defined in ECMA262 7.4
|
||||
// https://tc39.es/ecma262/#sec-operations-on-iterator-objects
|
||||
|
||||
Object* get_iterator(Object& obj, String hint = "sync", Value method = {});
|
||||
Object* get_iterator(GlobalObject&, Value value, String hint = "sync", Value method = {});
|
||||
bool is_iterator_complete(Object& iterator_result);
|
||||
Value create_iterator_result_object(Interpreter&, GlobalObject&, Value value, bool done);
|
||||
|
||||
Value iterator_next(Object& iterator, Value value = {});
|
||||
Value iterator_value(Object& iterator_result);
|
||||
Value iterator_step(Object& iterator);
|
||||
Object* iterator_next(Object& iterator, Value value = {});
|
||||
void iterator_close(Object& iterator);
|
||||
|
||||
void get_iterator_values(GlobalObject&, Value value, AK::Function<IterationDecision(Value&)> callback);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue