-
Notifications
You must be signed in to change notification settings - Fork 629
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
feat(io): iterateReader[Sync]()
#4247
Conversation
These used to be called |
Yes. I slightly liked the name more. This is not a strong opinion. Happy to change it back if we'd like. |
They were originally I don't have strong opinions to them, but I'd like to hear more opinions from the community. |
I've now renamed them to |
iterate()
and iterateSync()
toIterator()
and toIteratorSync()
Is there a risk of ambiguity with |
No risk of ambiguity that I'm aware of. |
I'm concerned that the name "toIterator" might not be descriptive enough that it targets a OTOH, I think we have |
Almost any unary generator function can be called |
Valid points by all. Which sounds better; |
+1
|
toIterator()
and toIteratorSync()
toReaderIterator()
and toReaderIteratorSync()
Ok, I think I've settled for |
Are we happy with the name now? |
'ReaderIterator' sounds a bit strange to me as I've never heard of that word combination in js context.
Also does |
It could also be Personally I'd prefer to have the noun "iterator" over the verb "iterate" because the function itself doesn't really iterate: it produces an iterator, which then can be iterated later, or never. It's different from |
No, but IMO, it shouldn't. The function neither reads nor iterates. @Leokuma makes this same point, which I agree with. The function converts a |
The problem is the methods on iterator also don't convey that IO is taking place -- they convey 'give me the next element'. That's why it's fine to say it in the generator function's name. To me it's similar to an async function, you don't need to add |
My opinion on this isn't strong enough to block this PR. Would we be happy with just resorting to the original |
My opinion isn't strong either. I'm fine with |
toReaderIterator()
and toReaderIteratorSync()
iterateReader[Sync]()
Name restored to the original |
I'd like to explore some other ideas. How about the below candidates:
|
I agree with Nayeem that the function name should contain "iterate". |
Nayeem suggests it should include
I think what this API does is similar to |
Maybe we should have been comparing this to It also occurred to me that we shouldn't bring back the non-sync version. Why wouldn't that one be deprecated when its aforementioned siblings are, and why do they need to be coupled? We should just bring back By the way an old discussion from when Sorry for the scattered thoughts. I think we should:
|
I don't think deprecation (again) of
The purpose of BTW I think this topic is far beyond this PR. |
|
Is there any interest in having this be part of the runtime API (say on FsFile) by implementing Symbol.iterator and Symbol.asyncIterator? I feel this would be in line with the Deno philosophy: aligning with Web APIs and JS primitives. Personally I love working with iterators as I think they are a great abstraction and should be treated as first class. |
However, If it's out of the question then I would like to throw the following into the ring: iterateChunks(); Iterate chunks tells me 2 things I want to know:
I liked the chunks from I noticed a few options used "Reader" but I don't think the input type is too important in the function name because I would aim to optimise for reading and it should already be obvious what the input is e.g. Alternatively instead of chunks we could have:
|
Thank you for the suggestions and opinions. We discussed this internally and decided to go with the original names |
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
While working on deprecation documentation, I realised that there's no new means for synchronous iteration for the
ReaderSync
interface. I thought we might as well un-deprecate this functionality, along with its asynchronous sibling.Note: this hasn't yet been decided upon.