-
Notifications
You must be signed in to change notification settings - Fork 0
β¨ feat(array-methods): add Array.Unshift method
#14
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
Merged
Conversation
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
Reviewer's GuideImplements a new Array.Unshift utility by prepending an element to a tuple via variadic tuple spread, complete with JSDoc, unit tests, script integration, and changelog entry. Class diagram for the new Array.Unshift typeclassDiagram
class Array {
<<namespace>>
}
class Unshift {
<<type>>
+<Arr extends unknown[], E extends unknown> [E, ...Arr]
}
Array <|.. Unshift : contains
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @AshGreyG - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `test/lib-Array.test.ts:20` </location>
<code_context>
Expect<Equal<Array.CreateArrayFromLength<0>, []>>,
Expect<Equal<Array.CreateArrayFromLength<-1>, []>>,
+ // Array.Unshift
+ Expect<Equal<Array.Unshift<[1,2,3], 4>, [4,1,2,3]>>,
+ Expect<Equal<Array.Unshift<[], []>, [[]]>>,
+ Expect<Equal<Array.Unshift<[1], []>, [[],1]>>,
+ Expect<Equal<Array.Unshift<[], 1>, [1]>>,
+
// Array.MultipleConcat
</code_context>
<issue_to_address>
Missing tests for edge cases with complex element types in Array.Unshift.
Please add tests for unshifting arrays, objects, and union types to verify Unshift handles complex element types correctly.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
Expect<Equal<Array.Unshift<[1,2,3], 4>, [4,1,2,3]>>,
Expect<Equal<Array.Unshift<[], []>, [[]]>>,
Expect<Equal<Array.Unshift<[1], []>, [[],1]>>,
Expect<Equal<Array.Unshift<[], 1>, [1]>>,
=======
Expect<Equal<Array.Unshift<[1,2,3], 4>, [4,1,2,3]>>,
Expect<Equal<Array.Unshift<[], []>, [[]]>>,
Expect<Equal<Array.Unshift<[1], []>, [[],1]>>,
Expect<Equal<Array.Unshift<[], 1>, [1]>>,
// Array.Unshift edge cases with complex element types
Expect<Equal<Array.Unshift<[{a: 1}, {b: 2}], {c: 3}>, [{c: 3}, {a: 1}, {b: 2}]>>,
Expect<Equal<Array.Unshift<[[1, 2], [3, 4]], [5, 6]>, [[5, 6], [1, 2], [3, 4]]>>,
Expect<Equal<Array.Unshift<[1 | 2, 3], 4 | 5>, [4 | 5, 1 | 2, 3]>>,
Expect<Equal<Array.Unshift<[], {foo: string; bar: number}>, [{foo: string; bar: number}]>>,
Expect<Equal<Array.Unshift<[{x: number}], {y: boolean}>, [{y: boolean}, {x: number}]>>,
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click π or π on each comment and I'll use the feedback to improve your reviews.
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.
π Description
This PR introduces a new method of
Arraynamespace:Array.Unshift<Arr, E>π΄ PR Type
π₯ Linked issues
πΎ Additional context
β³ Change log
Summary by Sourcery
Introduce the
Array.Unshifttype helper to the Array namespace for prepending elements to tuple types, and register corresponding tests and changelog updatesNew Features:
Array.Unshift<Arr, E>type to prepend an element to tuple typesDocumentation:
Array.UnshiftTests:
Array.Unshiftinlib-Array.test.tsand update thelib-genscript for its test cases