Add repeat function#8
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new repeat() function to the common stdlib utilities that executes a given action function a specified number of times, with each iteration receiving a zero-based index parameter.
Key changes:
- Implements the
repeat()function with proper JSDoc documentation - Adds comprehensive test coverage for positive, zero, and negative input scenarios
- Updates documentation and navigation to include the new function
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/stdlib/common/repeat.ts | Core implementation of the repeat function |
| src/stdlib/common/repeat.spec.ts | Unit tests covering various scenarios |
| src/stdlib/common/index.ts | Export statement for the new function |
| docs/api/core/kotlin-stdlib/kotlin/repeat.md | API documentation with usage examples |
| docs/.vitepress/config.mts | Navigation menu entry for the documentation |
Comments suppressed due to low confidence (2)
src/stdlib/common/repeat.spec.ts:5
- The test description 'should repeat a value n times' is misleading. The function doesn't repeat a value, it executes an action function n times. Consider changing to 'should execute action n times'.
it('should repeat a value n times', () => {
src/stdlib/common/repeat.spec.ts:8
- The test verifies that the action is called 3 times but doesn't verify that the correct index values (0, 1, 2) are passed to each call. Consider adding assertions to verify the action is called with the expected index values.
expect(action).toHaveBeenCalledTimes(3)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Features
repeat()function.