-
Notifications
You must be signed in to change notification settings - Fork 0
β¨ feat(array-methods): add Array.Reverse and Array.Shift methods
#13
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
Conversation
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.
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> `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.
| /** | ||
| * 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| /** | |
| * 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<[]>; // [] | |
| */ |
π 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