✨ feat(array-methods): add new Array.LastIndexOf method of Array namespace#12
Merged
✨ feat(array-methods): add new Array.LastIndexOf method of Array namespace#12
Array.LastIndexOf method of Array namespace#12Conversation
…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.
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.
Comment on lines
+93
to
+96
| 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.
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.
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 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: