discord.js icon indicating copy to clipboard operation
discord.js copied to clipboard

feat(collection): support `findLast` and `reduceRight` methods

Open jaw0r3k opened this issue 2 years ago • 2 comments

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 findLast and findLastKey methods to Collection class to search for the last item or key that satisfies a predicate function (link)
  • Add reduceRight method to Collection class 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)

jaw0r3k avatar May 15 '23 17:05 jaw0r3k

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

vercel[bot] avatar May 15 '23 17:05 vercel[bot]

Codecov Report

Merging #9573 (5fd2bdc) into main (c051ed9) will increase coverage by 0.21%. The diff coverage is 93.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!

codecov[bot] avatar May 16 '23 15:05 codecov[bot]

I know this isn't in the ES2023 spec but would there be room to add a getLast?

ImRodry avatar Jul 22 '23 15:07 ImRodry

there already is last() method @ImRodry

jaw0r3k avatar Jul 29 '23 12:07 jaw0r3k

⚡️ 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/

github-actions[bot] avatar Oct 03 '23 19:10 github-actions[bot]