Files
discord.js/packages/collection
René ea042458a3 perf(collection): optimisations (#10552)
* perf: `merge()`: deduplicate boolean checks

* perf: `toSorted()`: remove redundant closure

* perf: `last[Key]()`: order of operations

- do not perform iterable-to-array until required
- test ! before <

* perf: `{at,keyAt}()`: manually iterate to target

* perf: `first[Key]()`: avoid `Array.from()`

* perf: `map()`: avoid `Array.from()`

* perf: `random[Key]()`: avoid `Array.from()`

* test: `.{at,keyAt}()` indices

* perf: `last[Key]()`: use `.at()`/`.keyAt()` for single element

* perf: `first[Key]()`: use iterable-to-array if returning all

* perf: `random[Key]()`: use `{at,keyAt}()` for single value

- skip iterable-to-array for returning single value
- short-circuit if amount or collection size is zero

* perf: `random[Key]()`: use Durstenfeld shuffle

* refactor: `{key,keyAt}()`: reorder index check

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-11-07 11:03:26 +00:00
..
2023-05-03 02:14:22 +02:00
2023-05-03 02:14:22 +02:00
2022-06-07 10:51:33 +02:00


discord.js


Discord server npm version npm downloads Build status Code coverage

Vercel Cloudflare Workers

About

@discordjs/collection is a powerful utility data structure used in discord.js.

Installation

Node.js 18 or newer is required.

npm install @discordjs/collection
yarn add @discordjs/collection
pnpm add @discordjs/collection

Contributing

Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the documentation.
See the contribution guide if you'd like to submit a PR.

Help

If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official discord.js Server.