-
Notifications
You must be signed in to change notification settings - Fork 238
Add Iterator.zip #1274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add Iterator.zip #1274
Conversation
| @@ -1,10 +1,10 @@ | |||
| ;(function(Array, TypeError, asyncIterator, defineProperty, iterator) { | |||
| ;(function(Array, TypeError, Symbol·asyncIterator, Object·defineProperty, Symbol·iterator) { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cute, innit?
| @@ -0,0 +1,210 @@ | |||
| ;(function(IteratorHelper, InternalError, TypeError, call, Symbol·iterator) { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A thing to keep in mind when reviewing this file: it's almost impossible to change or reorder anything here without breaking some test262 tests.
|
I'll do a full review shortly, bun in the meantime, some food for thought: do we want to have each of these as a separate file or maybe have a |
|
With a single .js file there's no lazy-loading of individual built-ins; it's all or nothing. |
Fair enough! |
cd2a98a to
0ed8683
Compare
|
@saghul if you could find it in you to review this pr and the other one? |
saghul
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a suggestion!
| @@ -0,0 +1,210 @@ | |||
| ;(function(IteratorHelper, InternalError, TypeError, call, Symbol·iterator) { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ;(function(IteratorHelper, InternalError, TypeError, call, Symbol·iterator) { | |
| ;(function(IteratorHelper, InternalError, TypeError, call, Symbol.iterator) { |
Was that a weird middle dot rather than a period?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see now we are pasing the symbol straight. It mislead me, so may I suggest SymbolIterator ?
| if (item.done) break | ||
| let iter = item.value | ||
| check(iter, "bad iterator") | ||
| let method = iter[Symbol·iterator] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let method = iter[Symbol·iterator] | |
| let method = iter[Symbol.iterator] |
| throw e | ||
| } | ||
| // note: uses plain numbers for |state|, using | ||
| // constants grows the bytecode by about 200 bytes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I assume this is why you wrote it so compact 😅
| let alive = count | ||
| return { | ||
| __proto__: IteratorHelper, | ||
| // TODO(bnoordhuis) shows up as "at next (<null>:0:1)" in stack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mark it as TODO because it can be fixed?
I initially tried to do this in C but it was so onerous I decided to switch to JS. Marginally less onerous but still a massive PITA to implement.
Iterator.zipKeyedis up next.