fix: Remove use of reduce in keysSorter function#416
Closed
theluckystrike wants to merge 3 commits intosindresorhus:mainfrom
Closed
fix: Remove use of reduce in keysSorter function#416theluckystrike wants to merge 3 commits intosindresorhus:mainfrom
theluckystrike wants to merge 3 commits intosindresorhus:mainfrom
Conversation
Replaced Array.reduce with a simpler for...of loop for better readability and to address the TODO comment in the codebase. This refactor makes the code easier to understand and maintains the same functionality.
The padding-line-between-statements ESLint rule requires a blank line before return statements. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
This removes the use of |
Author
CI Status Update ✅This PR now has passing CI on all Node.js versions! The latest CI run (22622952176) passed successfully on both Node.js 18 and Node.js 20. The earlier failure (run 22615360834) was resolved by adding an additional commit with linting fixes. |
Repository owner
locked and limited conversation to collaborators
Mar 3, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 addresses the TODO comment in the codebase by replacing the use of
Array.reducewith a simplerfor...ofloop in thekeysSorterfunction.Changes
reducewith afor...ofloop for better readabilityunicorn/no-array-reduceWhy
The TODO comment indicated that
reduceshould be removed. This refactor makes the code:Testing
The existing test suite should cover this functionality. Please run
npm testto verify.