Skip to content

feat!: allow lossless crushconstruct use - #387

Open
mikerowe81 wants to merge 2 commits into
radashi-org:nextfrom
mikerowe81:main
Open

feat!: allow lossless crushconstruct use#387
mikerowe81 wants to merge 2 commits into
radashi-org:nextfrom
mikerowe81:main

Conversation

@mikerowe81

@mikerowe81 mikerowe81 commented Mar 29, 2025

Copy link
Copy Markdown

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

aleclarson commented Apr 10, 2025

Copy link
Copy Markdown
Member

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
Copy Markdown
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

radashi-bot commented Apr 11, 2025

Copy link
Copy Markdown

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
Copy Markdown
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