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

Introduce first() and last() Functions for Components #105

Open
KhudaDad414 opened this issue Nov 20, 2023 · 0 comments
Open

Introduce first() and last() Functions for Components #105

KhudaDad414 opened this issue Nov 20, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@KhudaDad414
Copy link
Member

Context:

Currently, when working with AsyncAPI, accessing the first or last component requires using array indexing, like so:

parsedAsyncAPI.channels().all().filter((c) => c.address() === address())[0]

This method, while effective, can be less intuitive and may not clearly convey the developer's intent.

Proposed Solution

I propose adding first() and last() functions to the parser-api. These functions would allow users to directly retrieve the first or last component in a more readable and straightforward manner. The proposed usage would be:

// For the first channel
parsedAsyncAPI.channels().all().filter((c) => c.address() === address).first()

// For the last channel
parsedAsyncAPI.channels().all().filter((c) => c.address() === address).last()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant