Skip to content

feat!: allow lossless crushconstruct use #387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

mikerowe81
Copy link

@mikerowe81 mikerowe81 commented Mar 29, 2025

Summary

Updates crush and construct functions to support empty arrays, empty objects, and undefined values

Related issue, if any:

#386

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 next-minor.md or next-major.md have been added, if needed

Does this PR introduce a breaking change?

No

Bundle impact

Status File Size 1 Difference
M src/object/crush.ts 581 +296 (+104%)
M src/object/set.ts 442 -23 (-5%)

Footnotes

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

@mikerowe81 mikerowe81 requested a review from aleclarson as a code owner March 29, 2025 00:46
@aleclarson
Copy link
Member

aleclarson commented Apr 10, 2025

I'd like to avoid using isEmpty in this change, since it's quite heavy and definitely overkill in this case.

Also, can you retarget this PR at the next branch? Thanks!

@aleclarson aleclarson added the BREAKING CHANGE Not backwards compatible label Apr 10, 2025
@mikerowe81 mikerowe81 changed the base branch from main to next April 11, 2025 14:31
@mikerowe81
Copy link
Author

@aleclarson Rather than isEmpty, what do you think of just using the object test from isEmpty?

!Object.keys(value).length

P.S. I'm still relatively new to the whole pull request thing, so I think I figured out how to retarget to next but now it says I want to merge 10 commits, so if I'm doing something wrong, please let me know. Thanks

@radashi-bot
Copy link

radashi-bot commented Apr 11, 2025

Benchmark Results

Name Current Baseline Change
crush ▶︎ with valid input 100,615.21 ops/sec ±0.57% 121,757.45 ops/sec ±0.29% 🔗 🐢 -17.36%
set ▶︎ with simple path 1,267,794.8 ops/sec ±0.41% 1,323,137.6 ops/sec ±0.5% 🔗 🐢 -4.18%
set ▶︎ with deep path 736,025.94 ops/sec ±0.42% 740,590.64 ops/sec ±0.24% 🔗 🐢 -0.62%
set ▶︎ with array index path 504,651.97 ops/sec ±0.34% 511,717.86 ops/sec ±0.25% 🔗 🐢 -1.38%
set ▶︎ with numeric key 671,567.22 ops/sec ±0.55% 717,082.75 ops/sec ±0.09% 🔗 🐢 -6.35%

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.

@radashi-org radashi-org deleted a comment from socket-security bot Apr 11, 2025
@aleclarson aleclarson changed the title fix(crush & construct): To support empty arrays, empty objects, and undefined values fix!: allow lossless crushconstruct use Apr 12, 2025
@aleclarson aleclarson changed the title fix!: allow lossless crushconstruct use feat!: allow lossless crushconstruct use Apr 12, 2025
@aleclarson aleclarson added this to the v13.0.0 milestone Apr 12, 2025
@MarlonPassos-git
Copy link
Contributor

@mikerowe81 @aleclarson Since there was no documentation before about what this function returns, wouldn’t it be worth adding examples showing how it handles empty values?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BREAKING CHANGE Not backwards compatible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants