Skip to content

feat(utilities): add iterableToArray helper#643

Closed
MrkMrk00 wants to merge 1 commit into
masterfrom
feat/add-iterable-collect-helpers
Closed

feat(utilities): add iterableToArray helper#643
MrkMrk00 wants to merge 1 commit into
masterfrom
feat/add-iterable-collect-helpers

Conversation

@MrkMrk00
Copy link
Copy Markdown

This PR adds a new utility used to collect items from an iterable (or an async iterable) into an array.

Inspiration :) https://www.php.net/manual/en/function.iterator-to-array.php

@MrkMrk00 MrkMrk00 requested a review from Copilot May 27, 2026 11:37
@MrkMrk00 MrkMrk00 self-assigned this May 27, 2026
@MrkMrk00 MrkMrk00 added the adhoc Ad-hoc unplanned task added during the sprint. label May 27, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@github-actions github-actions Bot added t-infra Issues with this label are in the ownership of the infrastructure team. tested Temporary label used only programatically for some analytics. labels May 27, 2026
@MrkMrk00 MrkMrk00 requested a review from Copilot May 27, 2026 11:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread packages/utilities/src/streams_utilities.ts Outdated
@MrkMrk00 MrkMrk00 force-pushed the feat/add-iterable-collect-helpers branch from 522e8b2 to 08f0974 Compare May 27, 2026 11:56
@MrkMrk00 MrkMrk00 force-pushed the feat/add-iterable-collect-helpers branch from 08f0974 to e44b81d Compare May 27, 2026 11:57
Comment on lines +34 to +41
async function asyncIterableToArray<T>(iterable: AsyncIterable<T>): Promise<T[]> {
const out: T[] = [];
for await (const item of iterable) {
out.push(item);
}

return out;
}
Copy link
Copy Markdown
Member

@B4nan B4nan May 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the same as Array.fromAsync(), no?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:O Did not know about that one. This was my use case mainly, closing the PR. Thanks

@MrkMrk00 MrkMrk00 closed this May 27, 2026
@MrkMrk00 MrkMrk00 deleted the feat/add-iterable-collect-helpers branch May 27, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-infra Issues with this label are in the ownership of the infrastructure team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants