discord.js
discord.js copied to clipboard
feat(collection): support `findLast` and `reduceRight` methods
Please describe the changes this PR makes and why it should be merged:
🤖 Generated by Copilot at 9150f28
This pull request enhances the Collection class with new methods that mirror the Array class. These methods provide more options for working with collections of data, such as finding the last element that matches a predicate or applying a function from right to left. The new methods are implemented in packages/collection/src/collection.ts.
- Add
findLastandfindLastKeymethods toCollectionclass to search for the last item or key that satisfies a predicate function (link) - Add
reduceRightmethod toCollectionclass to apply a function to each item of the collection from the last one and accumulate a single value (link)
Status and versioning classification:
- I know how to update typings and have done so, or typings don't need updating
- This PR changes the library's interface (methods or parameters added)
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| discord-js | ❌ Failed (Inspect) | Nov 5, 2023 6:45pm | ||
| discord-js-guide | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Nov 5, 2023 6:45pm |
Codecov Report
Merging #9573 (5fd2bdc) into main (c051ed9) will increase coverage by
0.21%. The diff coverage is93.25%.
@@ Coverage Diff @@
## main #9573 +/- ##
==========================================
+ Coverage 60.04% 60.26% +0.21%
==========================================
Files 235 235
Lines 16025 16105 +80
Branches 1216 1231 +15
==========================================
+ Hits 9622 9705 +83
+ Misses 6359 6356 -3
Partials 44 44
| Flag | Coverage Δ | |
|---|---|---|
| collection | 99.23% <93.25%> (-0.64%) |
:arrow_down: |
| next | ∅ <ø> (∅) |
|
| proxy | 75.00% <ø> (ø) |
|
| rest | 92.77% <ø> (ø) |
|
| ws | 52.63% <ø> (ø) |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Files | Coverage Δ | |
|---|---|---|
| packages/collection/src/collection.ts | 99.23% <93.25%> (-0.64%) |
:arrow_down: |
... and 1 file with indirect coverage changes
:mega: Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!
I know this isn't in the ES2023 spec but would there be room to add a getLast?
there already is last() method @ImRodry
⚡️ Lighthouse report for the changes in this PR:
| Category | Score |
|---|---|
| 🟢 Performance | 100 |
| 🟢 Accessibility | 100 |
| 🟢 Best practices | 92 |
| 🟢 SEO | 92 |
| 🟠 PWA | 67 |
Lighthouse ran on https://discord-js-git-fork-jaw0r3k-findlast-discordjs.vercel.app/