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

Symbol.asyncIterator on FileSystemDirectoryHandle? #158

Closed
jimmywarting opened this issue Mar 7, 2020 · 3 comments · Fixed by #177
Closed

Symbol.asyncIterator on FileSystemDirectoryHandle? #158

jimmywarting opened this issue Mar 7, 2020 · 3 comments · Fixed by #177
Milestone

Comments

@jimmywarting
Copy link

have experimented with the API a bit, could not help but feel like FileSystemDirectoryHandle is missing Symbol.asyncIterator that maps to getEntries

for await (const entry of dirHandle) { ... }
@pwnall pwnall changed the title asyncIterator for getEntries Symbol.asyncIterator on FileSystemDirectoryHandle? Mar 29, 2020
@mkruisselbrink
Copy link
Contributor

Good question, doesn't seem unreasonable to me, although that would also mean that getEntries would be called getValues instead (and possibly there would be a getEntries as well, that would return a iterator of name->child pairs instead). All of that seems not too crazy, although getValues does seem like a bit of a weird name for the method to return the children of a directory...

@DanielHerr
Copy link

What does the handle being async iterable have to due with renaming getEntries to getValues?

@mkruisselbrink
Copy link
Contributor

Actually I misremembered things slightly, values() and/or entries() were the methods I was thinking of.

The way WebIDL currently defines async iterables (https://heycam.github.io/webidl/#idl-async-iterable), as well as the proposed additions in whatwg/webidl#808 for value iterables automatically result in a values() method being defined on the async iterable object, as well as possible a entries() and keys() method if it is a pair iterable as opposed to a value iterable.

So in the simplest case of just marking the handle as async iterable<FileSystemHandle>, we would also get a values() method that does what getEntries() does today. If on the other hand we define it as async iterable<USVString, FileSystemHandle> (i.e. a map of names to handles) we would still get a values() method that does what getEntries() does today, but inaddition there would also be a keys() method (that just returns the names) and a entries() method that returns pairs of name+handle (a bit redundant since the handle already contains the name as well, but probably not the end of the world?).

Especially in that second case I don't think it makes sense to have entries() and getEntries() methods that return somewhat different things, so then I'd just drop getEntries() (with values() being its replacement). In the first case I suppose we could keep getEntries() as an alias for values(), but that still seems potentially confusing...

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

Successfully merging a pull request may close this issue.

3 participants