GitShow/sindresorhus/sort-keys
sindresorhus

sort-keys

Sort the keys of an object

by sindresorhus
Star on GitHubForknpm

JavaScript

109 stars22 forks11 contributorsActive · 5d agoSince 2014v6.0.1MIT

Meet the team

See all 11 on GitHub →
sindresorhus
sindresorhus30 contributions
kevva
kevva3 contributions
coreyfarrell
coreyfarrell2 contributions
hong4rc
hong4rc1 contribution
BendingBender
BendingBender1 contribution
jamestalmage
jamestalmage1 contribution
kenrick95
kenrick951 contribution
nathanfdunn
nathanfdunn1 contribution

Languages

View on GitHub →
JavaScript94.5%
TypeScript5.5%

Commit activity

Last 12 weeks · 2 commits

Full graph →

Community health

4 of 6 standards met

Community profile →
85
✓README✓License✓Contributing✓Code of Conduct○Issue Template○PR Template

Recent fixes

View closed PRs →
hong4rc
Fix off-by-one `depth` for keys inside array elementsMergedPR

What's wrong with a depth-limited function reorders an object it should have left alone — anything nested inside an array element is processed one level too early. Using the exact path the docs document — lists as depth : / are unaffected (they never use ). The bug only shows with the depth-based function form, and only for objects nested inside arrays. Why it happens should equal the key's nesting level — — which documents ( → ). An array element sits at , so: a nested array recurses at — adds its own for its elements; a nested object must recurse at — its keys are one level deeper than the element, and reports keys at exactly the depth it's given. The bug recursed the object at (the element's own depth), collapsing the element's keys onto it. Fix Snapshot the element depth once () and recurse with for arrays and for objects. Reading this local snapshot — rather than — keeps recursion independent of the user's callback, which is handed the same object and could otherwise mutate . (With the fix, holds for every reported path.) Tests Added an assertion that a key inside an array element is one level deeper than the element. Full suite (41 tests) passes, and the new assertion fails without the fix.

hong4rc · 5d ago
btea
feat: add `ignore` optionMergedPR
btea · 10mo ago
btea
feat: add `ignoreKeys` optionMergedPR
btea · 11mo ago
Structured data for AI agents

Repository: sindresorhus/sort-keys. Description: Sort the keys of an object Stars: 109, Forks: 22. Primary language: JavaScript. Languages: JavaScript (94.5%), TypeScript (5.5%). License: MIT. Latest release: v6.0.1 (5d ago). Open PRs: 0, open issues: 0. Last activity: 5d ago. Community health: 85%. Top contributors: sindresorhus, kevva, coreyfarrell, hong4rc, BendingBender, jamestalmage, kenrick95, nathanfdunn, papb, Richienb and others.

·@ofershap

Replace github.com with gitshow.dev