Skip to content
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

Feature request: ES2018 GetIterator and CreateAsyncFromSyncIterator #66

Open
ExE-Boss opened this issue Nov 3, 2019 · 6 comments
Open

Comments

@ExE-Boss
Copy link
Contributor

ExE-Boss commented Nov 3, 2019

I’m currently writing a polyfill for the Iterator Helpers proposal, and I need these two methods.

@ExE-Boss ExE-Boss changed the title Feature request: ES2018 GetIterator and CreateAsyncFromSyncIterator Feature request: ES2018 GetIterator and CreateAsyncFromSyncIterator Nov 3, 2019
@ljharb
Copy link
Owner

ljharb commented Nov 3, 2019

GetIterator has been available since v1.11.0, afaik.

CreateAsyncFromSyncIterator is tricky; i don't currently have the intrinsic for AsyncFromSyncIteratorPrototype, so I'd need to add that as well; I'm also not sure that it's *possible to implement that in JS.

@ExE-Boss
Copy link
Contributor Author

ExE-Boss commented Nov 3, 2019

ES2018 added the optional hint parameter to the GetIterator abstract operation, in a backwards incompatible manner.

@ljharb
Copy link
Owner

ljharb commented Nov 4, 2019

ah yes. I’d have to throw on an async hint, though, until the other method you request was available.

@ExE-Boss
Copy link
Contributor Author

ExE-Boss commented Nov 4, 2019

Actually, GetIterator(obj, 'async') can be allowed return an async iterator if obj has a Symbol.asyncIterator property, and only throw when CreateAsyncFromSyncIterator is needed.

Also, there’s no way to access %AsyncFromSyncIteratorPrototype% from JS, and even if there were, you still couldn’t set its [[SyncIteratorRecord]] internal slot.

@ljharb
Copy link
Owner

ljharb commented Nov 5, 2019

right, so when would it be needed?

@ExE-Boss
Copy link
Contributor Author

ExE-Boss commented Nov 5, 2019

CreateAsyncFromSyncIterator is needed when obj doesn’t have a [Symbol.asyncIterator]() method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants