Repository navigation
📦🔥:keep non-plain objects whole in deep copies - #91
Conversation
deepAssign and deepMixin recursed into every object a source held, so a
function, a Date, a Map, a RegExp or a class instance came out as an
empty {}. They now copy only plain objects property by property and
assign everything else by reference, as _copyDeep already does inside
an array.
deepMerge, like the other two where the target already held an object,
merged a source Date or Map into the target's one. Neither carries its
state in own properties, so the target's old value survived. Only a
plain source object is merged now.
Signed-off-by: Derek Lewis <DerekNonGeneric@inf.is>
Assisted-by: Claude-Code:claude-opus-5
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (8)
Included review availability: This review used your included allowance. 3 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour. 📝 WalkthroughWalkthroughDeep assignment and mixin now recursively copy nested plain objects and arrays while retaining other values by reference. Deep merge now recursively merges plain source objects and replaces target values with other source values. ChangesDeep copy and merge behavior
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The changes consistently preserve non-plain values by reference while retaining recursive handling for plain objects. No concrete merge-blocking risk is established; merge after normal checks pass. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Requested by DerekNonGeneric
Before:
deepAssign({}, { fn, when: new Date(0), m: new Map(), re: /x/g })returned{ fn: {}, when: {}, m: {}, re: {} }.deepMixindid the same.deepMerge({ d: new Date(0) }, { d: new Date(5) })kept the old date, because it merged oneDateinto the other and aDatehas no own properties to copy.After: functions, Dates, Maps, RegExps and class instances are assigned by reference, and only plain objects are copied or merged property by property.
This is the rule
_copyDeepalready follows inside arrays.How:
_mixinanddeepMergenow check the source value withisPlainObjectbefore they recurse. Tests for all three helpers fail on main and pass here.Summary by CodeRabbit