✨ feat(array-methods): add Array.Reverse and Array.Shift methods#13
Merged
✨ feat(array-methods): add Array.Reverse and Array.Shift methods#13
Array.Reverse and Array.Shift methods#13Conversation
Reviewer's GuideImplements two new Array namespace utilities—Reverse and Shift—via recursive conditional types, refactors helper type defaults, updates the changelog, and adjusts Boolean.Not tests. Class diagram for new Array.Reverse and Array.Shift typesclassDiagram
class Array {
}
class Reverse {
<<type>>
+Reverse<Arr extends unknown[], Result extends unknown[] = []>
}
class Shift {
<<type>>
+Shift<Arr extends unknown[], Mode extends "get-rest"|"get-shift-element" = "get-rest">
}
Array <|.. Reverse : contains
Array <|.. Shift : contains
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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> `lib/Array/index.d.ts:361` </location>
<code_context>
export type Push<Arr extends unknown[], E extends unknown> = [...Arr, E];
+/**
+ * This method is like `Array.prototype.revers`, it reverses the array.
+ *
+ * @param Arr The array to be reversed.
</code_context>
<issue_to_address>
Typo in method description: 'revers' should be 'reverse'.
Please correct the typo in the description to 'reverse' to avoid confusion in the documentation.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
/**
* This method is like `Array.prototype.revers`, it reverses the array.
*
* @param Arr The array to be reversed.
* @param Result The array to store the final reversed result in the process
* procedure.
* @returns The reversed array.
*
* @example
* type Reverse1 = Array.Reverse<[1, 2, 3]>; // [3, 2, 1]
* type Reverse2 = Array.Reverse<[]>; // []
*/
=======
/**
* This method is like `Array.prototype.reverse`, it reverses the array.
*
* @param Arr The array to be reversed.
* @param Result The array to store the final reversed result in the process
* procedure.
* @returns The reversed array.
*
* @example
* type Reverse1 = Array.Reverse<[1, 2, 3]>; // [3, 2, 1]
* type Reverse2 = Array.Reverse<[]>; // []
*/
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Comment on lines
360
to
371
| /** | ||
| * This method is like `Array.prototype.revers`, it reverses the array. | ||
| * | ||
| * @param Arr The array to be reversed. | ||
| * @param Result The array to store the final reversed result in the process | ||
| * procedure. | ||
| * @returns The reversed array. | ||
| * | ||
| * @example | ||
| * type Reverse1 = Array.Reverse<[1, 2, 3]>; // [3, 2, 1] | ||
| * type Reverse2 = Array.Reverse<[]>; // [] | ||
| */ |
There was a problem hiding this comment.
issue (typo): Typo in method description: 'revers' should be 'reverse'.
Please correct the typo in the description to 'reverse' to avoid confusion in the documentation.
Suggested change
| /** | |
| * This method is like `Array.prototype.revers`, it reverses the array. | |
| * | |
| * @param Arr The array to be reversed. | |
| * @param Result The array to store the final reversed result in the process | |
| * procedure. | |
| * @returns The reversed array. | |
| * | |
| * @example | |
| * type Reverse1 = Array.Reverse<[1, 2, 3]>; // [3, 2, 1] | |
| * type Reverse2 = Array.Reverse<[]>; // [] | |
| */ | |
| /** | |
| * This method is like `Array.prototype.reverse`, it reverses the array. | |
| * | |
| * @param Arr The array to be reversed. | |
| * @param Result The array to store the final reversed result in the process | |
| * procedure. | |
| * @returns The reversed array. | |
| * | |
| * @example | |
| * type Reverse1 = Array.Reverse<[1, 2, 3]>; // [3, 2, 1] | |
| * type Reverse2 = Array.Reverse<[]>; // [] | |
| */ |
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.
📝 Description
This PR adds two new methods in
Arraynamespace:Array.Reverse<Arr>Array.Shift<Arr, Mode>🌴 PR Type
🔥 Linked issues
👾 Additional context
⛳ Change log
Summary by Sourcery
Introduce
Array.ReverseandArray.Shifttype utilities, refine existing array-type internals, and add Boolean.Not testsNew Features:
Array.Reverse<Arr>type to reverse tuple typesArray.Shift<Arr, Mode>type to extract shifted element or remaining tupleEnhancements:
unknown[]in array-type helpersDocumentation:
Tests:
Boolean.Nottest cases and update test script mapping for Boolean.Not