-
Notifications
You must be signed in to change notification settings - Fork 0
✨ feat(array-methods): add new Array.LastIndexOf method of Array namespace
#12
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
…ray.prototype.lastIndexOf`
Reviewer's GuideThis PR introduces a new type-level method Class diagram for the new Array.LastIndexOf typeclassDiagram
class Array {
<<namespace>>
}
class LastIndexOf {
<<type>>
+Arr: unknown[]
+T: unknown
+Count: 0[]
+returns: number
}
Array <|-- LastIndexOf : type
class IndexOf {
<<type>>
}
Array <|-- IndexOf : type
class CreateArrayFromLength {
<<type>>
}
class Integer {
<<namespace>>
}
class Dec {
<<type>>
}
Integer <|-- Dec : type
LastIndexOf ..> CreateArrayFromLength : uses
LastIndexOf ..> Integer.Dec : uses
LastIndexOf ..> IndexOf : similar pattern
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Array.LastIndexOf method of Array namespaceArray.LastIndexOf method of Array namespace
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:93` </location>
<code_context>
Expect<Equal<Array.At<[], 0>, never>>,
+ // Array.LastIndexOf
+ Expect<Equal<Array.LastIndexOf<[1,2,1,2,1,3,4], 1>, 4>>,
+ Expect<Equal<Array.LastIndexOf<[], 1>, -1>>,
+ Expect<Equal<Array.LastIndexOf<[1,2,3], 0>, -1>>,
+ Expect<Equal<Array.LastIndexOf<[[],[[]],[],[]], [[]]>, 1>>,
+
]
</code_context>
<issue_to_address>
Missing tests for edge cases with complex types and repeated non-primitive values.
Add tests for arrays with objects, symbols, functions, and cases like different object references or NaN to ensure correct LastIndexOf behavior with complex types and tricky equality scenarios.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| Expect<Equal<Array.LastIndexOf<[1,2,1,2,1,3,4], 1>, 4>>, | ||
| Expect<Equal<Array.LastIndexOf<[], 1>, -1>>, | ||
| Expect<Equal<Array.LastIndexOf<[1,2,3], 0>, -1>>, | ||
| Expect<Equal<Array.LastIndexOf<[[],[[]],[],[]], [[]]>, 1>>, |
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.
suggestion (testing): Missing tests for edge cases with complex types and repeated non-primitive values.
Add tests for arrays with objects, symbols, functions, and cases like different object references or NaN to ensure correct LastIndexOf behavior with complex types and tricky equality scenarios.
📝 Description
This PR adds a new method
Array.LastIndexOfof namespaceArray, this method is similar toArray.prototype.lastIndexOf, when the array doesn't contain the target element, this method will return -1.🌴 PR Type
🔥 Linked issues
👾 Additional context
⛳ Change log
Summary by Sourcery
Add a new type-level LastIndexOf method to the Array namespace and integrate corresponding tests and script updates
New Features:
Build:
Tests: