Skip to content

Conversation

@aleclarson
Copy link
Member

@aleclarson aleclarson commented Feb 5, 2025

Summary

Adds the isEmptyRecord function to check if a plain object has 0 own keys.

Related issue, if any:

https://github.com/orgs/radashi-org/discussions/356

For any code change,

  • Related documentation has been updated, if needed
  • Related tests have been added or updated, if needed
  • Related benchmarks have been added or updated, if needed
  • Release notes in .github/next-minor.md or .github/next-major.md have been added, if needed

Does this PR introduce a breaking change?

No

Bundle impact

Status File Size 1
A src/object/isEmptyRecord.ts 120

Footnotes

  1. Function size includes the import dependencies of the function.

@radashi-bot
Copy link

radashi-bot commented Feb 5, 2025

Benchmark Results

Name Current
isEmptyRecord: empty object 4,770,844.66 ops/sec ±0.13%
isEmptyRecord: object with one property 2,387,765.67 ops/sec ±0.09%
isEmptyRecord: object with multiple properties 2,383,043.41 ops/sec ±0.09%
isEmptyRecord: empty object 2,982,509.25 ops/sec ±0.25%
isEmptyRecord: object with one property 2,980,672.21 ops/sec ±0.09%

Performance regressions of 30% or more should be investigated, unless they were anticipated. Smaller regressions may be due to normal variability, as we don't use dedicated CI infrastructure.

@aleclarson
Copy link
Member Author

Thinking of splitting this into hasKeysIn and hasOwnKeysIn, as I suspect skipping the hasOwnProperty check is quite a bit faster, which is nice for cases where you're certain the prototype won't have enumerable keys. Though, I'm a bit unsure if this would be a wise choice, as it might create confusion for people. So, perhaps it's best to merge isEmptyRecord as it is.

@aleclarson aleclarson moved this to Proposed in Radashi Mar 19, 2025
@aleclarson aleclarson added open library This PR should be listed in the Open Library won't merge A rejected proposal. labels May 23, 2025
@aleclarson
Copy link
Member Author

Marking this as "won't merge" for now. It's unclear whether the use cases for this function are common enough to warrant inclusion in Radashi.

@aleclarson aleclarson moved this from Proposed to Won't Do in Radashi Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open library This PR should be listed in the Open Library won't merge A rejected proposal.

Projects

Status: Won't Do

Development

Successfully merging this pull request may close these issues.

2 participants