Skip to content

Implement percentage functions for random number generation #83

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Manya7547
Copy link

  • Added synchronous percentage() function to generate random percentages (0 to 1) with optional repetition.
  • Implemented asynchronous percentageAsync() function to generate random percentages asynchronously with optional repetition.
  • Created AsyncStream.percentage() to wrap percentageAsync() in an async stream.
  • Added Stream.percentage() to wrap percentage() in a synchronous stream.
  • Included error handling for negative repetitions using InvalidArgumentError.

These changes introduce support for both synchronous and asynchronous random percentage generation with flexible iteration options.

- Added synchronous percentage() function to generate random percentages (0 to 1) with optional repetition.
- Implemented asynchronous percentageAsync() function to generate random percentages asynchronously with optional repetition.
- Created AsyncStream.percentage() to wrap percentageAsync() in an async stream.
- Added Stream.percentage() to wrap percentage() in a synchronous stream.
- Included error handling for negative repetitions using InvalidArgumentError.

These changes introduce support for both synchronous and asynchronous random percentage generation with flexible iteration options.
@coveralls
Copy link

coveralls commented Mar 10, 2025

Pull Request Test Coverage Report for Build 13909962086

Details

  • 21 of 21 (100.0%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 13813571636: 0.0%
Covered Lines: 1481
Relevant Lines: 1481

💛 - Coveralls

@Smoren
Copy link
Owner

Smoren commented Mar 23, 2025

Hi @Manya7547! Thanks for your PR! It's mostly good, but there are a couple of things I'd like to improve.

I described a couple of little things in the review in the message above.

I also suggest reworking your tests a little so that they use data providers, as is currently implemented in other previously written tests.

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 this pull request may close these issues.

3 participants