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

suggestion: remove iterator argument from parseAll() in @std/yaml #5128

Closed
iuioiua opened this issue Jun 25, 2024 · 1 comment · Fixed by #5148
Closed

suggestion: remove iterator argument from parseAll() in @std/yaml #5128

iuioiua opened this issue Jun 25, 2024 · 1 comment · Fixed by #5148
Labels
suggestion a suggestion yet to be agreed yaml

Comments

@iuioiua
Copy link
Collaborator

iuioiua commented Jun 25, 2024

I suggest removing the iterator argument from parseAll().

It provides no added value to the function as it doesn't affect the return array and is only called on each YAML document (element) once all documents are already loaded onto memory. If a user really needs this functionality, they can use Array.prototype.forEach().

https://github.com/denoland/deno_std/blob/a4d4e51cfad1fd79eae5c70bdb8b0d6f92a591d7/yaml/_loader/loader.ts#L1773-L1789

@kt3k
Copy link
Member

kt3k commented Jun 27, 2024

This makes sense to me. The first signature of parseAll() (one with iterator) can be easily replaced with the below pattern:

-parseAll(yaml, iterator, options);
+parseAll(yaml, options).forEach(iterator);

There seem no special scenario supported only by the 1st signature. (If there's an error in any of the input, both cases seem throwing at the same point).

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

Successfully merging a pull request may close this issue.

2 participants